Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using cPanel Apache 2 on my VPS server to host PHP / MySQL websites on port 80.

So let's say we have which just works fine.

Now I installed Ruby / Rails / Passenger with nginx (also with Ruby Entreprise Edition) which runs fine on port 3000. Let's say I have a new Ruby on Rails app and would like to host it on and not

How should I make this happen?

I configure a domain in nginx as follows:

server {
   listen 3000;
   root /home/myruby/public; 
   passenger_enabled on;

If I change the port to 80 then it's not working (obviously conflicts with Apache). Please note that I do not add the domain to the cPanel.

I have 2 dedicated IP addresses. I have heard somewhere that with 2 IPs you can solve this problem. But how do you instruct cPanel's Apache to only listen on a specific IP? Also, if I point a domain to my server how can I instruct the RoR domains to point to the RoR IP?

share|improve this question
up vote 1 down vote accepted

For future reference who tries to run cPanel Apache and Ruby on Rails with nginx.

1) Configure nginx like this:

server {
    root /home/yourrubydomain/public; 

1) Just add the Add-on domain in cPanel 2) Log in to FTP, navigate to the WWW directory of the newly added domain 3) Create a .htaccess file with the following content:

RewriteRule ^ "http\:\/\/\:8001%{REQUEST_URI}" [P,QSA,L]

4) That's it! 5) At your second Ruby on Rails domain do not forget to try a different port than the first one. So for example, at use port 8002, instead of 8001, both in the nginx and .htaccess configuration.

share|improve this answer

There you go, learn about mod_proxy and ProxyPass.

share|improve this answer
And what do you think of this solution? RewriteEngine on RewriteCond %{HTTP_HOST} ^$ [OR] RewriteCond %{HTTP_HOST} ^$ RewriteRule ^demo "http\:\/\/127\.0\.0\.1\:3000%{REQUEST_URI}" [P,QSA,L] – James Aug 28 '09 at 14:57
Basically, you are proxying without using the mod_proxy module. Congrats, you win. – David Rickman Aug 29 '09 at 7:24

You can tell Apache to listen only on certain IPs in the httpd.conf file. Default is probably

Listen 80

Change it to

Listen XXX:80

Where XXX is the first IP you want apache to listen on.

You can then set up nginx to listen on the other IP

listen YYY:80

Alternatively, you could configure Apache to use mod_proxy to do a reverse proxy so that certain domains will forward to localhost:3000 and use the nginx server. But I think the above solution is better because it adds less complexity to the system.

Note that you might fight with cPanel on the change because it will tend to re-write that file when it is upgraded or you make changes to domains.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.