# HTTPS header missing from single server

**URL:** <https://www.ruby-forum.com/t/https-header-missing-from-single-server/227288>\
**Category:** NGINX\
**Created:** [March 10, 2013, 6:51am UTC](https://www.ruby-forum.com/t/https-header-missing-from-single-server/227288 "2013-03-10T06:51:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 10, 2013, 6:51am UTC](https://www.ruby-forum.com/t/https-header-missing-from-single-server/227288/1 "2013-03-10T06:51:27Z")

</div>

How can I make nginx set the HTTPS header in a single http/https  
server? piwik with force\_ssl=1 on apache goes into a redirect loop  
because it doesn’t know SSL is on due to the nginx reverse proxy.  
There is a piwik bug which references a similar problem and blames the  
HTTPS header:

> <https://github.com/matomo-org/matomo/issues/2073>
>
> I am running piwik on nginx with php-fpm and I have configured a vhost for port …80 and one for 443. Both work just fine and I am able to login and use piwik via https.
> 
> However if I enable "force\_ssl\_login" Safari throws a "Too many redirects" error.
> 
> When using curl -k -v https://my-host.com/ I'm getting another 
> HTTP/1.1 302 Moved Temporarily
> Location: https://my-host.com/
> 
> Is there maybe a header that is missing like X-FORWARDED-PROTO?
> Keywords: ssl

- Grant

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 10, 2013, 11:41am UTC](https://www.ruby-forum.com/t/https-header-missing-from-single-server/227288/2 "2013-03-10T11:41:11Z")

</div>

On Sat, Mar 09, 2013 at 09:51:02PM -0800, Grant wrote:

Hi there,

> How can I make nginx set the HTTPS header in a single http/https  
> server?

What is “the HTTPS header”?

> piwik with force\_ssl=1 on apache goes into a redirect loop  
> because it doesn’t know SSL is on due to the nginx reverse proxy.

This sounds like one or more fastcgi\_param key/value pairs are not set  
the way your application wants them to be set.

[Module ngx\_http\_fastcgi\_module](http://nginx.org/r/fastcgi_param) is how you set them. And it  
includes an example with the $https variable, which is described in  
[Module ngx\_http\_core\_module](http://nginx.org/en/docs/http/ngx_http_core_module.html#variables)

The usual nginx directive inheritance rules apply, so you’ll want to add  
your fastcgi\_param line to the correct place – possibly just after you  
include the external file.

## f

Francis D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 10, 2013, 11:25pm UTC](https://www.ruby-forum.com/t/https-header-missing-from-single-server/227288/3 "2013-03-10T23:25:11Z")

</div>

> > How can I make nginx set the HTTPS header in a single http/https  
> > server?
> 
> What is “the HTTPS header”?

I meant to say HTTPS environment variable.

> > piwik with force\_ssl=1 on apache goes into a redirect loop  
> > because it doesn’t know SSL is on due to the nginx reverse proxy.
> 
> This sounds like one or more fastcgi\_param key/value pairs are not set  
> the way your application wants them to be set.
> 
> [Module ngx\_http\_fastcgi\_module](http://nginx.org/r/fastcgi_param) is how you set them. And it  
> includes an example with the $https variable, which is described in  
> [Module ngx\_http\_core\_module](http://nginx.org/en/docs/http/ngx_http_core_module.html#variables)

I should have mentioned that I’m using proxy\_pass. I was able to get  
it working like this:

proxy\_set\_header X-Forwarded-Proto $scheme;

- Grant
