I have an apache virtual host for port 80 that hosts a rails 3 phusion passenger application. I would like some actions of the application to switch to https (port 443). What is the best way to share one instance of a phusion passenger rails application between two vhosts?
Right now, I have:
<VirtualHost *:80>
ServerName mycompany.com
ServerAlias www.mycompany.com
RackBaseURI /
DocumentRoot /home/ubuntu/mycompany/public
<Directory /home/ubuntu/mycompany/public >
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
and
<VirtualHost _default_:443>
ServerName shop.mycompany.com
SSLEngine On
ProxyPass / http://localhost/
ProxyPassReverse / http://localhost/
ProxyPreserveHost On
SSLCertificateFile /etc/ssl/...
SSLCertificateKeyFile /etc/ssl/...
SSLCertificateChainFile /etc/ssl/...
</VirtualHost>
I know this is not ideal at all. There must be a better way. I do not want all requests to go through https due to the overhead.
Mike
Related
I have a rails app (www.myapp.com) for which I am using Apache Passenger. The virtual host is configured as follows:
<VirtualHost *:80>
DocumentRoot "/var/www/myapp/current/public"
RailsEnv production
<directory "/var/www/myapp/current/public">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</directory>
RailsBaseURI /
</VirtualHost>
I have a blog which is hosted externally on some other domain, lets say www.myapp-blog.com. I want to 301 redirect any requests to www.myapp.com/blog or www.myapp.com/blog/* to the relevant pages on www.myapp-blog.com. Everything else should flow through my Rails app.
How should I modify the above virtual host configuration to achieve this?
use apache port forwarding technique...
<VirtualHost *:80>
ProxyPreserveHost On
ProxyRequests Off
ServerName www.myapp-blog.com
ServerAlias myapp-blog.com
ProxyPass / http://www.myapp.com/blog/
ProxyPassReverse / http://www.myapp.com/blog
</VirtualHost>
When I run my browser from my rails application on my debian server, the tree of my application appears in the browser.
I install and configure passenger and apache but it does not work.
Why?
Thanks
You most likely have your web server pointed at <some_path>/app instead of <some_path>/app/public.
Example Apache VirtualHost:
<VirtualHost *:443>
ServerName www.app.com
DocumentRoot "/var/app/current/public/"
CustomLog /var/log/apache2/app_log combined
ErrorLog /var/log/apache2/app_log
<Directory /var/app/current/public>
AllowOverride all
Options -MultiViews
</Directory>
SSLEngine on
SSLCertificateFile /etc/ssl/certs/app.crt
SSLCertificateKeyFile /etc/ssl/private/app.key
SSLCertificateChainFile /etc/ssl/certs/bundle.crt
</VirtualHost>
I have a linode server and was running a single website for dev purposes using webrick, now i want to put it into production and use Apache2 which I have installed and is up and running the classic It Work's! page which is expected.
Now I want to run multiple sites on this VPS I am using the current configuration which works fine for striaght HTML but will not run the web apps unless I run them on another port (rails s -p3500 etc) as port 80 is already taken up by Apache.
<VirtualHost *:80>
ServerName datumpoint.bizmodev.com
# ServerAlias *.example.com
DocumentRoot /var/www.bizmodev.com
<Directory "/var/www.bizmodev.com">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName homehounduk.co.uk
ServerAlias *.homehounduk.co.uk
DocumentRoot /var/www.homehounduk.co.uk
<Directory "/var/www.homehounduk.co.uk">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Do i need to use passenger or something else to get this working? i have tried changing the virtual hosts to different ports and stuff but just end up getting a 403.
Any help would be appreciated.
this line:
<VirtualHost *:80>
you are telling to your apache that it will listen to anything on port 80
it you change to something like this:
<VirtualHost www.myawesomeurl.com:80>
in this case you are telling apache that everything that comes as a request from this address (www.myawesomeurl.com) on port 80 will use that options.
I think you want something like this:
# Basically your home, like: www.myhome.com
<VirtualHost *:80>
ServerName datumpoint.bizmodev.com
# ServerAlias *.example.com
DocumentRoot /var/www.bizmodev.com
<Directory "/var/www.bizmodev.com">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
# Your custom site
<VirtualHost www.something.com:80>
ServerName homehounduk.co.uk
ServerAlias *.homehounduk.co.uk
DocumentRoot /var/www.homehounduk.co.uk
<Directory "/var/www.homehounduk.co.uk">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
and dont forget to point the www.something.com to the same ip as the www.myhome.com
Combine this with passenger and you will have one server running many rails apps and many php instances or html pages or anything you want.
I switched from WEBrick to Phussion Passenger following this guide: http://developer.apple.com/library/mac/#featuredarticles/PhusionRails/index.html.
I used PassengerPane to configure it.
Now I can access my app at myapp.local, instead of localhost:3000
However, I don't know how to access it from the outside. It used to be ip:3000
My vhost.conf file looks like this:
<VirtualHost *:80>
ServerName myapp.local
DocumentRoot "/Users/martin/myapp/public"
RackEnv development
<Directory "/Users/martin/myapp/public">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
You need to add ServerAlias YOURIP:
<VirtualHost *:80>
ServerName myapp.local
ServerAlias YOURIP
DocumentRoot "/Users/martin/myapp/public"
RackEnv development
<Directory "/Users/martin/myapp/public">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
You can add as many aliases as you want (with real domain names for example).
I am trying to configure SSL on my localhost using apache and phusion passenger. I am using virtualhosts.
I have the below configuration in sites-available/myapp
VirtualHost *:80
ServerName myapp
DocumentRoot /home/madhu/ror/myapp/public
RailsEnv development
Directory /home/madhu/ror/myapp/public
AllowOverride all
Options -MultiViews
Order allow,deny
allow from all
Directory
VirtualHost
VirtualHost *:443
ServerName myapp
DocumentRoot /home/madhu/ror/myapp/public
ProxyPass / http://myapp/
ProxyPassReverse / http://myapp/
ProxyPreserveHost On
RequestHeader set X_FORWARDED_PROTO 'https'
Directory /home/madhu/ror/myapp/public
AllowOverride all
Options -MultiViews
Order allow,deny
allow from all
Directory
SSLEngine On
SSLProxyEngine On
SSLCertificateFile /etc/ssl/certs/Thawte_Server_CA.pem
SSLProxyMachineCertificateFile /etc/ssl/certs/Thawte_Server_CA.pem
VirtualHost
The SSL is enabled and everything works fine. But when I go to the url https://myapp/login , it says "The requested URL /login was not found on this server". When I look at the apache logs I found out that the request is going to /var/www/login istead of /home/madhu/ror/myapp/public. This was the error log
[client 127.0.0.1] File does not exist: /var/www/login
Is there anything I am missing? Please help
Thanks.
I had to put
ServerName myapp
DocumentRoot /home/madhu/ror/myapp/public
RequestHeader set X_FORWARDED_PROTO 'https'
Directory /home/madhu/ror/myapp/public
AllowOverride all
Options -MultiViews
Order allow,deny
allow from all
Directory
SSLEngine On
SSLProxyEngine On
SSLCertificateFile /etc/ssl/certs/Thawte_Server_CA.pem
SSLProxyMachineCertificateFile /etc/ssl/certs/Thawte_Server_CA.pem
in default-ssl :P silly mistake