I have a CentOS VPS, running Apache. Previously I just used it for hosting a bunch of PHP and static HTML websites, under various domains, and everything worked fine.
Then I developed a simple Node.js app. I published it on my VPS, and it was accessible, if I put :3000 after my IP.
I did some research into how to make my Node app accessible under it's new domain name, while keeping the Apache config similar to how it is. The solution seems to be reverse proxying with Nginx.
Ultimately what I want is:
- All my old sites that are PHP and HTML apps, and are running on Apache, to still be accessible under there usual domains, on Apache (port :8081)
- My Node app (running on port :3000) to be accessible just through it's new domain name, without a port number required
What I currently have:
nginx.conf
user asykes;
error_log /var/log/nginx/error.log warn;
worker_rlimit_nofile 20480;
events {
worker_connections 5120; # increase for busier servers
use epoll; # you should use epoll here for Linux kernels 2.6.x
}
http{
include "/etc/nginx/sites-enabled/*";
}
And for my Node app config, sites-available/sentiment-sweep.conf (with symlink to site-enabled)
server {
listen 80;
server_name sentiment-sweep.com;
location / {
proxy_pass http://localhost:3000;
}
}
What this currently does
All domains on my server all resolve to my node app which is on port 3000
I need only http://sentiment-sweep.com/ to resolve to localhost:3000, and everything else to go to their Apache version on revisionquizzes.co.uk:8081/ and http://computerscience.as93.net:8081/ and so on...
I have spent hours playing around with nginx config, adding server{location{}} for the Apache port, but seem to be getting nowhere. The closest I got, was when it rendered the Apache Sorry page.
Any suggestions or help would be so much appreciated, thanks in advance