0

I have set up a Linode NodeBalancer to handle HTTPS traffic for my website, https://adamhelm.com, which listens on port 443. I have also set up an nginx server to route traffic to my Node.js application on port 3000 with the following nginx configuration:

    listen 443;
    server_name www.adamhelm.com;

    location / {
        proxy_pass http://localhost:3000;
        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;
    } 

When I try to access my website at https://adamhelm.com, I get a "502 Bad Gateway" error on my web browser. The error logs from NGINX show that there is a "Permission denied" error when trying to connect to the upstream server at http://45.79.140.133:3000. The connection to the upstream server is being made from the NodeBalancer with a private connection using the IP address 192.168.255.142.

I am able to access the app through the host's IP address directly at http://45.79.140.133:3000 without any issues.

I am looking for help to correctly configure this setup.

adamfhelm
  • 35
  • 8

1 Answers1

0

The Node.js app communication to NGINX requires opening outbound ports. Anyone wishing to leverage NGINX as a reverse proxies to Node.js with Linode NodeBalancers should be aware of this.

The solution for CentOS7 is:

Solution Reference URL

yum install policycoreutils-python 

semanage port --add --type http_port_t --proto tcp 8001
adamfhelm
  • 35
  • 8