# HTTPS - NGINX with Passenger webservers behind F5 load balancer

**URL:** <https://www.ruby-forum.com/t/https-nginx-with-passenger-webservers-behind-f5-load-balancer/204307>\
**Category:** NGINX\
**Created:** [March 9, 2011, 2:39pm UTC](https://www.ruby-forum.com/t/https-nginx-with-passenger-webservers-behind-f5-load-balancer/204307 "2011-03-09T14:39:28Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [March 9, 2011, 2:39pm UTC](https://www.ruby-forum.com/t/https-nginx-with-passenger-webservers-behind-f5-load-balancer/204307/1 "2011-03-09T14:39:28Z")

</div>

The setup looks like this:

```
              LOAD BALANCER WEBSERVERS

    443 | F5 Load Balancer | 80 /---> NGINX(with Passenger)

```

USER \<------\>| with SSL certificate |------|  
| installed | |----\> NGINX(with Passenger)  
|  
—\> NGINX(with Passenger)

Communication between user and load balancer is going through  
port 443 and between load balancer and webservers is going through  
port 80.

What would be the correct nginx configuration for webservers, so they  
don’t redirect https://… connections to http://…

---

<div class="post-metadata">

**Author:** ![jzmudzinski](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/278dde/32.png) [@jzmudzinski](https://www.ruby-forum.com/u/jzmudzinski)\
**Post date:** [March 9, 2011, 2:49pm UTC](https://www.ruby-forum.com/t/https-nginx-with-passenger-webservers-behind-f5-load-balancer/204307/2 "2011-03-09T14:49:49Z")

</div>

In my case of such config I was able to force perl application to build  
links inside with https. If your links don’t have any scheme, then  
user’s browser will use existing one.

Also, you should avoid rewrites with schemes on nginx side.

i.e. rewrite ^ [http://example.com/](http://example.com/) permanent; should be avoided, because  
it enforces to use http.

---

<div class="post-metadata">

**Author:** ![jzmudzinski](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/278dde/32.png) [@jzmudzinski](https://www.ruby-forum.com/u/jzmudzinski)\
**Post date:** [March 9, 2011, 2:56pm UTC](https://www.ruby-forum.com/t/https-nginx-with-passenger-webservers-behind-f5-load-balancer/204307/3 "2011-03-09T14:56:42Z")

</div>

On Wed, Mar 9, 2011 at 9:48 PM, Vitaly T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> In my case of such config I was able to force perl application to build  
> links inside with https. If your links don’t have any scheme, then user’s  
> browser will use existing one.
> 
> Also, you should avoid rewrites with schemes on nginx side.
> 
> i.e. rewrite ^ [http://example.com/](http://example.com/) permanent; should be avoided, because  
> it enforces to use http.

but you could also (and should) redirect to https instead?

-jf

---

<div class="post-metadata">

**Author:** ![jzmudzinski](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/278dde/32.png) [@jzmudzinski](https://www.ruby-forum.com/u/jzmudzinski)\
**Post date:** [March 9, 2011, 3:25pm UTC](https://www.ruby-forum.com/t/https-nginx-with-passenger-webservers-behind-f5-load-balancer/204307/4 "2011-03-09T15:25:34Z")

</div>

Today Mar 9, 2011 at 14:39 Jarek Zmudzinski wrote:

> Communication between user and load balancer is going through  
> port 443 and between load balancer and webservers is going through  
> port 80.
> 
> What would be the correct nginx configuration for webservers, so they  
> don’t redirect https://… connections to http://…

Rails honor X-Forwarded-Proto header.  
Try insert it on F5:  
[DevCentral](http://devcentral.f5.com/Forums/tabid/1082223/asg/50/showtab/groupforums/aff/5/aft/26643/afv/topic/Default.aspx)

–  
WNGS-RIPE

---

<div class="post-metadata">

**Author:** ![jzmudzinski](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/278dde/32.png) [@jzmudzinski](https://www.ruby-forum.com/u/jzmudzinski)\
**Post date:** [March 24, 2011, 1:25pm UTC](https://www.ruby-forum.com/t/https-nginx-with-passenger-webservers-behind-f5-load-balancer/204307/5 "2011-03-24T13:25:10Z")

</div>

Jarek Zmudzinski wrote in post #986664:

> What I would like is to NGINX listen to https:// on port 80 this way any  
> https request to F5 LB could still be taken care of by NGINX listening  
> on port 80 without being redirected to http. But I am afraid it’s not  
> possible.

Problem solved. It was a F5 configuration issue. NGINX doesn’t redirect  
https:// on port 80 to http://.

Thanks.

---

<div class="post-metadata">

**Author:** ![jzmudzinski](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/278dde/32.png) [@jzmudzinski](https://www.ruby-forum.com/u/jzmudzinski)\
**Post date:** [March 24, 2011, 6:40pm UTC](https://www.ruby-forum.com/t/https-nginx-with-passenger-webservers-behind-f5-load-balancer/204307/6 "2011-03-24T18:40:27Z")

</div>

Thanks for your follow up.

–  
Regards, Vitaly T.  
System A.  
U.S. +1 (206) 905-9939  
Russia +7 911 094-2035

---

<div class="post-metadata">

**Author:** ![jzmudzinski](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/278dde/32.png) [@jzmudzinski](https://www.ruby-forum.com/u/jzmudzinski)\
**Post date:** [March 10, 2011, 9:29am UTC](https://www.ruby-forum.com/t/https-nginx-with-passenger-webservers-behind-f5-load-balancer/204307/7 "2011-03-10T09:29:40Z")

</div>

Jeffrey Lim wrote in post #986479:

> but you could also (and should) redirect to https instead?

Yeah, but this way I would still have to setup nginx to listen on 443  
and include ssl\_certificate on NGINX webservers. This would result in  
secure communication on port 443 between F5 LB and NGINX webservers. I  
don’t want that.

What I would like is to NGINX listen to https:// on port 80 this way any  
https request to F5 LB could still be taken care of by NGINX listening  
on port 80 without being redirected to http. But I am afraid it’s not  
possible.

---

<div class="post-metadata">

**Author:** ![jzmudzinski](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/278dde/32.png) [@jzmudzinski](https://www.ruby-forum.com/u/jzmudzinski)\
**Post date:** [April 6, 2011, 5:11pm UTC](https://www.ruby-forum.com/t/https-nginx-with-passenger-webservers-behind-f5-load-balancer/204307/8 "2011-04-06T17:11:42Z")

</div>

I hate to read this kind of thread when the OP resolves the issue and  
post “Thanks! fixed”

You fixed doing what?

Explain so others shouldn’t need to ask it twice.

Thanks

Posted at Nginx Forum:

> **[Re: HTTPS - NGINX with Passenger webservers behind F5 load balancer](https://forum.nginx.org/read.php?2,181577,188794#msg-188794)**
>
> The setup looks like this: LOAD BALANCER WEBSERVERS 443 | F5 Load Balancer | 80 /---\> NGINX(with Passenger) USER \<------\>| with SSL certificate |------| | installed |

---

<div class="post-metadata">

**Author:** ![jzmudzinski](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/278dde/32.png) [@jzmudzinski](https://www.ruby-forum.com/u/jzmudzinski)\
**Post date:** [April 6, 2011, 5:13pm UTC](https://www.ruby-forum.com/t/https-nginx-with-passenger-webservers-behind-f5-load-balancer/204307/9 "2011-04-06T17:13:33Z")

</div>

On Apr 6, 2011, at 11:11 PM, genarg wrote:

> I hate to read this kind of thread when the OP resolves the issue and  
> post “Thanks! fixed”
> 
> You fixed doing what?
> 
> Explain so others shouldn’t need to ask it twice.

Agree!
