🤖Configure Backend (API)
After installing Nginx, create the Backend reverse-proxy configuration file using the command:
nano /etc/nginx/sites-available/api.domain.com.conf
Paste the configuration code below and change the IP to your machine's IP. Remember to add the port :3333 at the end, or if you used another port, put the port correctly.
server {
server_name 0.0.0.0:3333; #YourIP, example: 144.87.33.65:3333
location / {
proxy_pass http://localhost:3333;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
Ctrl + X and type Y hit Enter to save config file.
Link the file to nginx enabled section.
ln -s /etc/nginx/sites-available/api.domain.com.conf /etc/nginx/sites-enabled/api.domain.com.conf
Test if ok.
nginx -t
If you see long OK message done correctly. Else please do the steps correctly.
Restart nginx
service nginx restart
Last updated