Upstream server are always redirected as https

I am always redirect to https://mydomain … How can i STOP this?

upstream navi_profi_server {
server unix:/tmp/navi-profi.sock fail_timeout=0;
}

server {
listen 80;
client_max_body_size 4G;
server_name _;
keepalive_timeout 5;
root /home/navi-profi/app/current/;

location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;

if (!-f $request_filename) {
  proxy_pass http://navi_profi_server;
  break;
}

}

error_page 500 502 503 504 /500.html;
location = /500.html {
root /home/navi-profi/app/shared/public;
}
}

Posted at Nginx Forum:

On 29 June 2012 08:10, henn1nk [email protected] wrote:

I am always redirect to https://mydomain … How can i STOP this?

Nothing in the nginx config you posted is doing this. It’s almost
certainly your application that’s choosing to issue the redirect.
If I had to guess, I’d suggest that your app is redirecting you, a
non-logged-in user, to a login page, which it insists on serving over
HTTPS so your login creds can’t get sniffed.

You can verify that it’s the app that’s doing this by either

  • watching your app’s (not nginx’s) per-request logs and seeing a
    301/302 get issued or
  • doing a “curl -v” against the URI you’re hitting in your browser,
    and looking out for response headers that let you know it’s definitely
    app responding, not nginx (for example “X-Powered-By:”, etc) or
  • doing a “curl -v” against the app directly, without involving
    nginx, and seeing the 301/302 get issued.

Something like that, anyway; I hope you get the idea.

To stop this being a problem, you either need to

  • set up an SSL nginx server which informs the app that it’s a secure
    connection or
  • lie to the app, and tell it that the HTTP connection is actually
    secure
  • tell the app not to insist on an SSL login.

I’d suggest you do the first of these. The “X-Forwarded-Proto” header
may be your friend. Have a google.

HTH,
Jonathan

Jonathan M.
Oxford, London, UK
http://www.jpluscplusm.com/contact.html