# A question of configuring proxy redirect from http to https

**URL:** <https://www.ruby-forum.com/t/a-question-of-configuring-proxy-redirect-from-http-to-https/209715>\
**Category:** NGINX\
**Created:** [July 21, 2011, 5:12am UTC](https://www.ruby-forum.com/t/a-question-of-configuring-proxy-redirect-from-http-to-https/209715 "2011-07-21T05:12:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [July 21, 2011, 5:12am UTC](https://www.ruby-forum.com/t/a-question-of-configuring-proxy-redirect-from-http-to-https/209715/1 "2011-07-21T05:12:12Z")

</div>

Here is my configuration scenario.  
One nginx host and several upstream servers.  
For the upstream server, giving a request with URL “/abc”, it will  
redirect to “/abc/”.

The nginx config is:

upstream ups {  
server xxxxxxx;  
server xxxxxxx;  
…  
}

location / {  
proxy\_pass ups;  
proxy\_add\_header $host:$server\_port;  
}

Therefore, if user access

http://\<nginx\_host\>:\<nginx\_port\>/abc;

the upstream server will send the redirection:  
Location: http://\<nginx\_host\>:\<nginx\_port\>/abc/

Here everything looks fine.

But there is an extreme case:  
if nginx listen on https rather than http. I have to use something like  
“proxy\_redirect http://$host:$server\_port /” to convert http to https in  
the redirection Location URL. But for now proxy\_redirect doesn’t support  
var in the first arg. Maybe you will say the first arg of proxy\_redirect  
could be a plain literal. But users could use various ways to access  
nginx, like FQDN, host name, IP address (maybe multiple ones), localhost  
or some. So I have to write proxy\_redirect for each possibilities. Is  
this the best way I can do?

Posted at Nginx Forum:

> **[A question of configuring proxy redirect from http to https](https://forum.nginx.org/read.php?2,212714,212714#msg-212714)**
>
> Here is my configuration scenario. One nginx host and several upstream servers. For the upstream server, giving a request with URL "/abc", it will redirect to "/abc/". The nginx config is: upstream ups { server xxxxxxx;
