How to set up Nginx for nodejs and php?

Asked

Viewed 228 times

1

I’m here trying to set up a basic server at digitalocean, where I wanted when accessing meudominio.com it redirect to the program in nodejs+express running at port 3000 and accessing meudominio.com/blog redirect to the /var/www/blog where there is a blog made in wordpress..

Can someone help me with this?

  • You can put in your question how is your Nginx configuration file?

1 answer

2

Better you use subdomains, have DNS point to your server and use ngnix as 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 archive /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 archive /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, website with., and blog.site.com ;)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.