0

I have a reactjs application running at port 5000. I want to route the requests from nginx to the webapp.

I am getting the below log

2019/06/20 04:30:10 [error] 17709#17709: *67 connect() failed (111: Connection refused) while connecting to upstream, client: 72.163.217.106, server: 159.65.123.84, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8000/", host: “example.com”
2019/06/20 04:30:10 [error] 17709#17709: *69 connect() failed (111: Connection refused) while connecting to upstream, client: 72.163.217.106, server: 159.65.123.84, request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:8000/favicon.ico", host: “example.com”, referrer: "http://example.com/“
2019/06/20 04:30:10 [error] 17709#17709: *71 connect() failed (111: Connection refused) while connecting to upstream, client: 72.163.217.106, server: 159.65.123.84, request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:8000/favicon.ico", host: “example.com”, referrer: "http://example.com/“

Here are my nginx config file at /etc/nginx/sites-available/default

server {
    listen 0.0.0.0:80;
    server_name example.com; # or server_name subdomain.yourapp.com;

    location / {
        proxy_pass http://127.0.0.1:5000;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-NginX-Proxy true;

        # Enables WS support
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_redirect off;
    }
}

what could be the reason for this kind of behavior. How to fix this issue.

wandermonk
  • 103
  • 12

1 Answers1

0

Seems like you are passing the requests to port 8000 in your nginx configuration. Try passing them to port 5000 because as per your post your ReactJS app is running on port 5000.