0

I am installing a site under my machine. I have a NodeJS server that listens on port 4000. I am using an NGINX reverse proxy, so that it is accessible from port 80. Here is the following configuration in / sites-availabes

upstream site {
  server 127.0.0.1:4000;
}

server {
   listen 80;
   server_name site.infra.monsite.blog;
   
   location / {
       proxy_pass http://site;
       proxy_http_version 1.1;
       proxy_set_header Upgrade $http_upgrade;
       proxy_set_header Host $host;
       proxy_cache_bypass $http_upgrade;
   }
}

But I can't access my site from site.infra.monsite.blog; which points to port 80 of the machine. Are there any ports to open like on Windows, or an NGINX configuration that I missed?

Yet when I do "curl -X GET http://localhost/": It works on the machine. Thanks for your help.

1
  • yes, port 80 http should be open in your firewall and domain should point to the machine Commented Sep 21, 2020 at 10:16

1 Answer 1

1

Try this:

upstream site {
  server 127.0.0.1:4000;
  keepalive 64;
}


server {
    listen 80;
    server_name www.example.com;
    return 301 https://www.example.com$request_uri;
}


location / {
    proxy_pass http://site;
    proxy_http_version 1.1;
    proxy_redirect off;
    proxy_pass_header  Set-Cookie;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-NginX-Proxy true;
    proxy_pass_header X-XSRF-TOKEN;
    proxy_read_timeout 240s;
   }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.