First, unlink the default configuration which shows Nginx Welcome page on port 80 using the command
path /etc/nginx/sites-enabled
$ sudo unlink default
Create a new .conf
file with reverse proxy configuration
path /etc/nginx/conf.d
$ sudo nano sites.conf
Use the following config for each reverse proxy that you want to apply
server {
listen 80 default_server;
server_name yourdomain.com www.yourdomain.com;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://localhost:3000;
}
}
server {
listen 80;
server_name yourdomain.in www.yourdomain.in;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://localhost:5000;
}
}
Now, test your configurations using:
$ sudo nginx -t
Check nginx status to verify that everything is working properly
$ sudo systemctl status nginx
Restart the server to apply changes using:
$ sudo systemctl restart nginx