# Pasenger,rails-2.3.8,apache 2.2.21

**URL:** <https://www.ruby-forum.com/t/pasenger-rails-2-3-8-apache-2-2-21/212675>\
**Category:** Deployment\
**Created:** [October 10, 2011, 2:21pm UTC](https://www.ruby-forum.com/t/pasenger-rails-2-3-8-apache-2-2-21/212675 "2011-10-10T14:21:31Z")\
**Posts on this page:** 2\
**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:** [October 10, 2011, 2:21pm UTC](https://www.ruby-forum.com/t/pasenger-rails-2-3-8-apache-2-2-21/212675/1 "2011-10-10T14:21:31Z")

</div>

Hello,

I am configuring apache 2.2 to serve my rails app through passenger. Im  
trying to host in 3 tier architecture.Making web server alone in https ,  
app server code is placed running in http.First, I’m redirect all http  
traffic to https with the following:

This is my web server apache conf file.

ServerName sampleapp

NameVirtualHost \*:80  
\<VirtualHost _:80\>  
Options FollowSymLinks  
RewriteEngine On  
RewriteCond %{SERVER\_PORT} !^443$  
RewriteRule ^._$ https://%{SERVER\_NAME}%{REQUEST\_URI} [L,R]

Inside the \<VirtualHost \*:443\> section, I have the following  
configuration, which seems extremely standard:  
  
Options FollowSymLinks  
AllowOverride None  
Order deny,allow  
Deny from none  
Allow from all  
  
ProxyPreserveHost on

ErrorLog “/usr/local/apache2/logs/error\_log”  
TransferLog “/usr/local/apache2/logs/access\_log”  
SSLEngine on

\<Proxy balancer://hotcluster\>  
BalancerMember [http://appserver:8010/](http://appserver:8010/)

ProxyPass / balancer://hotcluster/  
ProxyPassReverse / balancer://hotcluster/

SSLCipherSuite  
ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL

SSLCertificateKeyFile “/home/sasi/test.key”

SSLCACertificateFile “/home/sasi/test.cer”

SSLCertificateChainFile “/home/sasi/test1.cer”

\<FilesMatch “.(cgi|shtml|phtml|php)$”\>  
SSLOptions +StdEnvVars  
  
\<Directory “/usr/local/apache2/cgi-bin”\>  
SSLOptions +StdEnvVars

BrowserMatch “._MSIE._”   
nokeepalive ssl-unclean-shutdown   
downgrade-1.0 force-response-1.0

CustomLog “/usr/local/apache2/logs/ssl\_request\_log”   
“%t %h %{SSL\_PROTOCOL}x %{SSL\_CIPHER}x "%r" %b”

RequestHeader set X\_FORWARDED\_PROTO “https”

RewriteEngine On  
RewriteCond %{SERVER\_PORT} !^443$  
RewriteRule ^.\*$ https://%{SERVER\_NAME}%{REQUEST\_URI} [L,R]

RewriteCond %{HTTPS} !=on  
RewriteRule ^/(.\*) https://%{SERVER\_NAME}%{REQUEST\_URI} [L,R]

```
ProxyRequests Off
<Proxy *>
    Order Allow,Deny
    Allow from all
    AuthType Basic
    AuthName Transmission
    AuthUserFile /etc/apache2/users

```

# Require user me

```
</Proxy>

```

In my app server i point my application which runs with passenger ,  
apache in 8010 port

\<VirtualHost \*:8010\>  
RailsEnv development  
DocumentRoot /home/appserver/sampleapp/public

 Options FollowSymLinks AllowOverride None Order deny,allow Deny from none Allow from all ProxyPreserveHost on

RequestHeader set X\_FORWARDED\_PROTO “https”

ProxyPass /images !  
ProxyPass /stylesheets !  
ProxyPass /javascripts !

RewriteEngine on  
RewriteCond %{REQUEST\_METHOD} ^(HEAD|TRACE|DELETE|TRACK) [NC]  
RewriteRule ^(.\*)$ - [F,L]

RewriteCond %{REQUEST\_METHOD} !^(OPTIONS|GET|POST)$ [NC]  
RewriteRule .\* - [F,L]

When I point my browser to “[https://sampleapp/session/new](https://sampleapp/session/new)” I get the  
login page that I expect. After giving the login credentials my site url  
changes from https to http as ([http://sampleapp/home](http://sampleapp/home)) instead of staying  
in ([https://sampleapp/home](https://sampleapp/home)). If i manually change the url to “https”. It  
stays fully in https .

The way in which i have written rewrite condition in app server and web  
server is right?

Can anybody suggest me .

Please Help!

Sasi

---

<div class="post-metadata">

**Author:** ![sasidaran\_s](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ecb155/32.png) [@sasidaran\_s](https://www.ruby-forum.com/u/sasidaran_s)\
**Post date:** [August 20, 2012, 5:10pm UTC](https://www.ruby-forum.com/t/pasenger-rails-2-3-8-apache-2-2-21/212675/2 "2012-08-20T17:10:53Z")

</div>

I’d put this in your \<VirtualHost \*:80\> block instead of redirecting  
based on port:

# ssl redirect for any URL

RewriteCond %{SERVER\_PROTOCOL} !^HTTPS  
RewriteRule (.\*) https://%{HTTP\_HOST}$1 [R]
