# Https and the Host header

**URL:** <https://www.ruby-forum.com/t/https-and-the-host-header/193860>\
**Category:** NGINX\
**Created:** [August 25, 2010, 6:27pm UTC](https://www.ruby-forum.com/t/https-and-the-host-header/193860 "2010-08-25T18:27:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![janine](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/85f322/32.png) [@janine](https://www.ruby-forum.com/u/janine)\
**Post date:** [August 25, 2010, 6:27pm UTC](https://www.ruby-forum.com/t/https-and-the-host-header/193860/1 "2010-08-25T18:27:49Z")

</div>

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 [http://dev.mysite.com](http://dev.mysite.com)  
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 [dev.mysite.com](http://dev.mysite.com), and somewhere along the  
way an assumption gets made that that is http. I have tried setting  
Host to [https://dev.mysite.com](https://dev.mysite.com) 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  
it?

Thanks in advance!

Posted at Nginx Forum:

> **[https and the Host header](https://forum.nginx.org/read.php?2,123625,123625#msg-123625)**
>
> 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 http://dev.mysite.com...

---

<div class="post-metadata">

**Author:** ![janine](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/85f322/32.png) [@janine](https://www.ruby-forum.com/u/janine)\
**Post date:** [August 26, 2010, 6:37pm UTC](https://www.ruby-forum.com/t/https-and-the-host-header/193860/2 "2010-08-26T18:37:21Z")

</div>

try this:

```
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-Server ssl;
proxy_set_header HTTPS 1;

```

and then let the app ask for one of these headers.

Posted at Nginx Forum:

> **[Re: https and the Host header](https://forum.nginx.org/read.php?2,123625,123962#msg-123962)**
>
> 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 http://dev.mysite.com...
