I am trying to mount a reverse proxy with nginx in an instance that only deals with proxy as a function of the route, and the servers are in other instances, this is the configuration:
server {
# SSL configuration
#
listen 443 ssl default_server;
listen [::]:443 ssl default_server;
ssl_certificate /etc/nginx/ssl/ssl.crt;
ssl_certificate_key /etc/nginx/ssl/ssl.key;
server_name _;
location /app1/{
rewrite ^/app1(.*) /$1 break;
auth_basic "Restricted"; #For Basic Auth
auth_basic_user_file /etc/nginx/.htpasswd;
proxy_pass http://<IP-SERVER1:PORT;
}
location /app2/{
rewrite ^/app2(.*) /$1 break;
proxy_pass http://<IP-SERVER2:PORT;
auth_basic "Restricted"; #For Basic Auth
auth_basic_user_file /etc/nginx/.htpasswd;
}
So far, well, because the requests arrive at the server in particular, in one of the servers I hope to receive the request in / and make the request to the local server flask, the problem comes when flask treats the routes, theoretically it should be link But use: link > and arrives at the reverse proxy and gives 404. The configuration of app2:
server{
listen 8787 default_server;
listen [::]:8787 default_server;
server_name _;
location / {
proxy_pass http://127.0.0.1:7000/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwared-For $proxy_add_x_forwarded_for;
}
}
Thank you very much !!