https and the Host header

janine nginx-forum at
Wed Aug 25 20:27:02 MSD 2010

I am using Nginx as a proxy in front of a Java application (because it's
hosted at Amazon where we only get one IP address per system, and I am
running multiple sites).

When the application calls getRequestURL, it gets
regardless of whether the request was actually http or https.

I am guessing that this is because Host gets set to either $host or
$http_host, both of which are, and somewhere along the
way an assumption gets made that that is http.  I have tried setting
Host to but that returns a completely empty page
- I assume that means it's an invalid value for the Host header.

I have spent quite a bit of time researching this and I have found that
Django users experience a similar problem and the fix is to add a header
like X-Url-Scheme and pass along the value of $scheme, which will be
https at the appropriate times.  However, I don't see other Java users
reporting similar problems, and the fix seems kind of kludgy to me.

Does this mean I have something configured incorrectly, or is this just
the way it works?  And if so is the above the best way to work around

Thanks in advance!

Posted at Nginx Forum:,123625,123625#msg-123625

More information about the nginx mailing list