0

I just try to make a specific location for my domain, with a proxy_pass:

   location /new/ {
        proxy_pass        http://192.168.9.6:10061;
        proxy_set_header  X-Real-IP  $remote_addr;
        proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header  Host $http_host;
        proxy_redirect    off;
  }

http://mysite/new/ should point to the service open un port 10061 on machine 192.168.9.6.

But it's not the case, I just have a 404.
If I put a return 403 in this location, I have a forbidden, so the location is ok, but the proxy_pass is not effective.

The thing is, this is working:

   location / {
        proxy_pass        http://192.168.9.6:10060;
        proxy_set_header  X-Real-IP  $remote_addr;
        proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header  Host $http_host;
        proxy_redirect    off;
   }

It's the same kind of service on 2 port, the only difference is the /new vs root. So I don't understand what I misunderstood.

Edit:

This is what I see on nginx log when hit domain.com/new:

xx.xx.xx.xx - - [17/May/2018:14:16:35 +0200] "GET /new/ HTTP/1.1" 404 209 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:59.0) Gecko/20100101 Firefox/59.0"

And this is the log in server in 192.168.9.6:

2018-05-17 12:16:36,806 1 INFO p2plegal werkzeug: 192.168.9.1 - - [17/May/2018 12:16:36] "GET /new/ HTTP/1.0" 404 -

And this my complete nginx configuration for this domain:

upstream manage-old {
   server       192.168.9.6:10060;   #Production
}

upstream manage-new {
   server       192.168.9.6:10061;   #Production
}

server {
   server_name     manage.mydomain.com;
   listen 443 ssl;
   listen [::]:443 ssl;

   location / {
    proxy_pass        http://manage-old;
        proxy_set_header  X-Real-IP  $remote_addr;
        proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header  Host $http_host;
        proxy_redirect    off;
   }

   location /new/ {
        proxy_pass        http://manage-new;
        proxy_set_header  X-Real-IP  $remote_addr;
        proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header  Host $http_host;
        proxy_redirect    off;
  }

   location ~ /web/database/manager {
     auth_basic "Admin only";
     auth_basic_user_file /etc/nginx/.htpasswd-admin;

     proxy_pass http://manage-old;
   }

   location ~ /web/database/selector {
     auth_basic "Admin only";
     auth_basic_user_file /etc/nginx/.htpasswd-admin;

     proxy_pass http://manage-old;
   }

    ssl_certificate /etc/letsencrypt/live/manage.mydomain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/manage.mydomain.com/privkey.pem;
}


server {
    if ($host = manage.mydomain.com) {
        return 301 https://$host$request_uri;
    }

   server_name     manage.mydomain.com;
   listen 80;
   return 404;

}

0 Answers0