Welcome! Log In Create A New Profile

Advanced

Reverse proxy from HTTPS to HTTP from an unknown source location

July 22, 2011 04:43PM
I've searched these forums and the internet and haven't found anyone asking/answering this particular question. Hopefully I'm just missing something obvious in the configuration options that make this easy..

I've got a configuration where nginx will listen on both HTTP and HTTPS, and reverse proxy to a back-end server over only HTTP. This is a pretty simple configuration, however, with the HTTPS connection, the back-end server returns Location: headers with HTTP (instead of HTTPS) which need to be fixed. I do this like so:

location / {
proxy_pass http://mybackendserver:8080;
proxy_redirect http://myknown.host.com/ https://$host:$server_port/;
}

This works when I know the host that will be returned to match (ex: "myknown.host.com"), however, our target environment is a private network where clients each NAT their own IP's and internal DNS to access this site over HTTPS.

In this environment, if a client DNS'd their route to our server as https://companyx.com/their/application, I presume the return Location: header would be "Location: http://companyx.com", while I need to rewrite it to use HTTPS as "Location: https://companxy.com".

Based on the documentation and experimation, it does not appear I can use any kind of variable or wildcard matching int he first portion of the proxy_redirect configuration option.

Is there another way to accomplish this? The end goal is to reverse proxy from HTTPS to a back-end HTTP server, and fix the Location: headers on the responses to be HTTPS (as they should be, since the client accessed the site over HTTPS).

I'm not opposed to changing the way I reverse proxy if that's causing the problem.

Thanks,
Subject Author Posted

Reverse proxy from HTTPS to HTTP from an unknown source location

alex.sherwin July 22, 2011 04:43PM

Re: Reverse proxy from HTTPS to HTTP from an unknown source location

speedfirst July 22, 2011 11:32PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 318
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