# Upstream server are always redirected as https

**URL:** <https://www.ruby-forum.com/t/upstream-server-are-always-redirected-as-https/221070>\
**Category:** NGINX\
**Created:** [June 29, 2012, 9:11am UTC](https://www.ruby-forum.com/t/upstream-server-are-always-redirected-as-https/221070 "2012-06-29T09:11:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [June 29, 2012, 9:11am UTC](https://www.ruby-forum.com/t/upstream-server-are-always-redirected-as-https/221070/1 "2012-06-29T09:11:31Z")

</div>

I am always redirect to [https://mydomain](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:

> **[upstream server are always redirected as https](https://forum.nginx.org/read.php?2,228086,228086#msg-228086)**
>
> 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 \_; keepaliv

---

<div class="post-metadata">

**Author:** ![henn1nk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/58956e/32.png) [@henn1nk](https://www.ruby-forum.com/u/henn1nk)\
**Post date:** [June 29, 2012, 4:00pm UTC](https://www.ruby-forum.com/t/upstream-server-are-always-redirected-as-https/221070/2 "2012-06-29T16:00:35Z")

</div>

On 29 June 2012 08:10, henn1nk [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I am always redirect to [https://mydomain](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

> **[Jonathan Matthews :: Words Typed, Great Rates For Cash](https://www.jpluscplusm.com)**
