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/
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
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” 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) instead of staying
in (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