Reputation: 1774
I have this nginx config
events {
worker_connections 1024;
}
http {
server {
listen 443 ssl;
server_name 192.168.52.89;
ssl on;
ssl_certificate /path/config/certfile.crt;
ssl_certificate_key /path/config/keyfile.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
location /auth-foo {
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_pass_header Set-Cookie;
proxy_pass http://192.168.52.89:2085;
}
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_pass_header Set-Cookie;
proxy_pass http://192.168.51.90:3000;
}
}
}
I've looked at this file several times and cross checked with resources online and somehow this still doesn't work well. I expect that when a request is made as: 192.168.52.89/auth-foo
nginx should push the request to http://192.168.52.89:2085
but what I get is not found. Is there something I'm missing?
Am I missing something important?
Thank you.
Upvotes: 0
Views: 694
Reputation: 22994
Try the following:
server {
listen 443 ssl;
server_name 192.168.52.89;
ssl on;
ssl_certificate /path/config/certfile.crt;
ssl_certificate_key /path/config/keyfile.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
location = /auth-foo {
return 302 /auth-foo/; # Note the trailing slash
}
location /auth-foo/ { # Note the trailing slash
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_pass_header Set-Cookie;
proxy_pass http://192.168.52.89:2085/; # Note the trailing slash
}
Note the extra location
, and also note the trailing slashes in 3 places (comments added to highlight).
Upvotes: 1