How to configure Nginx for nodejs and php?

1

I'm here trying to set up a basic server on digitalocean, where I wanted to access mydomain.com when it redirected to the program on nodejs + express running on port 3000 and when accessing mydomain.com/blog redirect to / var / www / blog where you have a blog made in wordpress ..

Can anyone help me with this?

    
asked by anonymous 08.10.2014 / 19:49

1 answer

2

You'd better use subdomains, have DNS point to your server, and use ngnix as a proxy.

I've used it like this:

  • site1.com - > Node running local - > //127.0.0.1:4000
  • site2.com - > Node running local - > //127.0.0.1:5000

In the / etc / nginx / sites-enabled / site1

server {
    listen 80;
    server_name site1.com;
    access_log /var/log/nginx/site1.access.log;
    location / {
        proxy_pass    http://127.0.0.1:4000/;
    }
}

In the / etc / nginx / sites-enabled / site2

server {
    listen 80;
    server_name site2.com;
    access_log /var/log/nginx/site2.access.log;
    location / {
        proxy_pass    http://127.0.0.1:5000/;
    }
}

In case you just have to use site.com , and blog.site.com ;)

    
14.10.2014 / 02:55