1

I need to explain a problem. I need the output of the PATH content of an nginx reverse proxy to be sent to another domain that resides on another nginx server. Clear explanation: I have two linux servers "A" and "B", on the first server "A" I have a docker-like nginx with the following configuration:

server {
    listen       80;
    listen  [::]:80;
    server_name  example.com;
    location / {
        rewrite ^ https://$host$request_uri? permanent;
    }
}
server {
    listen       443 ssl http2;
    listen  [::]:443 ssl http2;
 
    server_name  example.com;
 
    ssl_certificate /etc/certs/x.pem;
    ssl_certificate_key /etc/certs/x.key;
    ssl_trusted_certificate /etc/certs/x.crt;
 
    location / {
      proxy_set_header        Host $host;
      proxy_set_header        X-Real-IP $remote_addr;
      proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header        X-Forwarded-Proto $scheme;
 
      proxy_pass          http://docker-api;
      proxy_read_timeout  90;
    }
    location /path {
    ...Help!!
    }
}

**This server "A" correctly serves the URL example.com with the proxy pass the content of the docker called "docker-api". Now the problem comes: I want to redirect all the content that is offered in the path "example.com/path" to another domain called "test.com" that is located in server "B".

Server "B" has another nginx with default configuration:**

    listen       80;
    listen  [::]:80;
    server_name  test.com;
 
    location / {
        rewrite ^ https://$host$request_uri? permanent;
    }
}
server {
    listen       443 ssl http2;
    listen  [::]:443 ssl http2;
 
    server_name  test.com;
 
    ssl_certificate /etc/certs/x.pem;
    ssl_certificate_key /etc/certs/x.key;
    ssl_trusted_certificate /etc/certs/x.crt;
    location / {
    }
}

How do I make the content that is served on server "A" in the path "example.com/path" arrive intact at the url "test.com" and be able to serve it through this last url? I hope someone can help me, thanks in advance

  • To me it looks you need to use `proxy_pass` also there, where the destination is the other nginx server. What have you tried and how did it fail? – Tero Kilkanen Feb 10 '22 at 19:53

0 Answers0