I have an app that has 3 different processes port 3000, 3001, 3002. I needed port 3000 to be mapped to port 443 (https) so the users don’t go to port 3000 to access the webpage. But the ports 3001, and 3002 are blocked. My current solution is to do open ports 3001, 3002 the same way as 3000, but that would not work as that will also map those ports to https.
Location block:
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
proxy_pass http://localhost:3000; #whatever port your app runs on
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;
}
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hi there @adityachandra,
If you do not have a firewall, in order to open the ports you would need to just start the specific services on those ports. Do you see all ports when running the following command:
If you have a firewall like UFW for example, and if you want to be able to access the ports directly, then you would need to open the ports with the following commands:
In case that you want to add another endpoint for your application like
/shop
for example, you could add an additionallocation
directive to your server block:If the new services are going to be completely separate websites with separate domain names, then you would need to create a new server block by coping the existing config file from
/etc/nginx/sites-available/your_conf
and updating the details accordingly. Then you could follow the steps here on how to enable the new server block and restart Nginx:https://www.digitalocean.com/community/tutorials/how-to-set-up-nginx-server-blocks-virtual-hosts-on-ubuntu-16-04
Hope that this helps. Regards, Bobby