multiple reverse proxy on same server not working with nginx

sakib11 asked:

I am running a flask server on port 5000 and my nginx config looks something like this:

server {
  listen 80;
  server_name xyz;

  location / {
      proxy_pass http://localhost:5000/;
  }
}

This is working just fine but now I need another server to run on this machine. So I made another file in conf.d/.

server {
  listen 80;
  server_name notxyz;

  location / {
      proxy_pass http://localhost:3000/;
  }
}

My server is running just fine but I can’t access the notxyz server despite it running on port 3000 (two apps now, on 5000 and on 3000). So I tried to open port 3000 on firewalld and this is how the settings on firewall-cmd –list-all look like;

public (active)
  target: default
  icmp-block-inversion: no
  interfaces: ens192
  sources: 
  services: dhcpv6-client http https ssh
  ports: 3000/tcp
  protocols: 
  masquerade: no
  forward-ports: 
  source-ports: 
  icmp-blocks: 
  rich rules: 

Yet I can’t access my site even via ip:3000. I have used nginx+firewalld before for many projects but not where I was running multiple proxy_pass on the same machine. This is driving me crazy. Can someone tell me where I am going wrong? Note that I also tried

  • Resetting firewalld
  • Reloading Firewalld
  • keeping the nginx config in the same file

The new app (on 3000) is running via flask so basic http requests. I try to access it via the browser. I mostly get a "refused to connect" error on the browser when accessing it via the ip;port and I get a forbidden error when i use the notxyz name.

My answer:


You’re running an app server on port 5000. You need to start your second app server on port 3000.


View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.