How do you run Nginx on port 8080 and Apache on port 80 on the same box?

I want to install Node.js on my box (CentOS 5) for testing and sandboxing but I can't uninstall Apache as recommend by developers using Nginx.

So what I'd like to do is have Nginx serving

nodejs.sandbox.net on IP 10.10.10.10

and Apache running (usual setup)

sandbox.net on 10.10.10.10

and then on my windows host file do something like

sandbox.net 10.10.10.10:80
nodejs.sandbox.net 10.10.10.10:8080

and by the way how do I install Nginx on CentOS 5 yum?


Solution 1:

You can use apache proxy to port 8080 for you. Set nginx to listen on port 8080. Create a virtualhost that will respond to the name nodejs.sandbox.net and set it up as a proxy for port 8080.

<VirtualHost *:80>
        ServerName  nodejs.sandbox.net
        ProxyRequests Off
        <Proxy *>
                Order deny,allow
                allow from all
        </Proxy>
        ProxyPreserveHost On
        ProxyPass / http://sandbox.net:8080
        ProxyPassReverse / http://sandbox.net:8080
        ProxyErrorOverride Off
        ErrorDocument 404 /notavail.html
</VirtualHost>