NGINX reverse proxy sometimes redirects to the wrong server

Viewed 12

I have two django applications running on the same server. Same hostname / same IP. I have it set up that anything at just / will go send user to app1 running on port 81 and anything with /miles will send user to app2 running backend on port 92. This configuration works great and perfectly MOST of the time. However, every now and then, users using app2, will click a link and it will redirect them to app1's home page. Click back, refresh, click again, it won't redirect now. Driving me nuts. Both back end servers are running the latest apache with WSGI configured. Anyone have any thoughts? Running windows server 2016.

NGINX.conf:



events {



worker_connections  4096;  ## Default: 1024
   }
http {

#for client authentication and sending headers to backends

map  $ssl_client_s_dn  $ssl_client_s_dn_cn {
   default "";
   ~CN=(?<CN>[^/,\"]+) $CN;
 }


server {



listen 80;



server_name myserver;




return 301 myserver$request_uri;



}

server {








server_name myserver;



#ssl on;

ssl_certificate  E:/Apache24/cert/public.cer;
ssl_certificate_key  E:/Apache24/cert/private.key; 
ssl_client_certificate E:/Apache24/cert/CAs.pem;
ssl_prefer_server_ciphers on;
ssl_verify_client on;
ssl_verify_depth 10;

location /miles {
    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_set_header        X-CC-CN $ssl_client_s_dn_cn;
    proxy_pass_request_headers on;

    proxy_pass http://myserver:92;
    proxy_redirect off;      
    #proxy_redirect default; 
                    }




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 https;
    proxy_set_header        X-CC-CN $ssl_client_s_dn_cn;
    proxy_pass_request_headers on;

    proxy_pass http://myserver:81/;   
    proxy_redirect off;           

                   }


   }
}
0 Answers
Related