Future Nate Note:
This is a terrible hack. You shouldn’t do this. You should use the apache passenger module mod_passenger
to run passenger behind apache.
This post rescribes how to proxy all traffic for a vhost to an internal port running a passenger standalone server. This is a bad way to do things. Follow this guide instead.
Original Post
I suspect many people don’t have this problem but I ran into it so I thought I’d document it. In order to minimize my AWS bill I wanted to run a website built in rails (this one!) on the same AWS instance that was already running apache. So if you need to do the same here’s what you do:
Run your rails app on a port other than port 80, anything works even if it’s not exposed to the public. The traffic will flow like this:
User -> Port (80) -> Apache -> Port (xyz) --> Rails
First you’ll need to install the necessary apache modules
Then, add a virtual host in your /etc/apache2/sites-enabled/something-something.conf file or wherever you specify your virtual hosts. It should look like this:
Restart apache with
or whatever tool you use to manage services.
And you’re golden, you now have a rails app and an apache server running simultaneously.