Welcome! Log In Create A New Profile

Advanced

A question of configuring proxy redirect from http to https

July 20, 2011 11:11PM
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?
Subject Author Posted

A question of configuring proxy redirect from http to https

speedfirst July 20, 2011 11:11PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 300
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready