Curl can download Nginx Virtual Host Site but browser gets connection refused

July 1, 2019 415 views
Nginx Node.js Ubuntu 18.04

I have configured nginx according to this tutorial and additionally I have changed the location to reverse proxy to my nuxt.js application on localhost:3000 according to this tutorial. I can

curl -i sevenlotus.co:80 

and it returns the full header of the site plus all of the html and css. Header is

HTTP/1.1 200 OK
Server: nginx/1.14.0 (Ubuntu)
Date: Mon, 01 Jul 2019 00:04:41 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 301997
Connection: keep-alive
ETag: "49bad-bEI6OAceinKEf1RyUfL3hbl/M3k"
Accept-Ranges: none

If i access sevenlotus.co through the browser I get ERRCONNECTIONREFUSED.

I cannot for the life of me figure out what is wrong. My /etc/nginx/sites-available/sevenlotus.co file is the following

server {
        listen 80;
        listen [::]:80;

        root /var/www/sevenlotus.co/html;
        index index.html index.htm index.nginx-debian.html;

        server_name sevenlotus.co www.sevenlotus.co;

        location / {
                #try_files $uri $uri/ =404;
                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;
        }
}

There is a proper sysmlink in /etc/nginx/sites-enabled/.
I tested the setting the location in the default server and I can access the site no problem (using the ip address of the machine). But if I go through the virtual host then I cannot connect via browser.

What am I missing?

6 comments
  • Hi there @seanaye2,

    With both CURL and a browser, http://sevenlotus.co/ now gives an Nginx 502 Bad Gateway page, do you still require help?

  • @MattIPv4 Thanks for your reply. Yes I still require help. The node process was down which is why you received 502. I have now daemonized the process with pm2. I can curl the app but still cannot access through any browser.

  • @seanaye2 how very odd. Have you tried using an incognito tab in your browser or an altogether different browser?

    When I attempt to access your site through my browser, I am greeted by your vuetify storefront

    - Matt.

  • I have added the hostname test.sevenlotus.co and added the same proxy config to the default server. I can access the site through a browser at test.sevenlotus.co which means the default server works fine but the virtual one at sevenlotus.co does not.

  • @MattIPv4 Very strange I have tried Chrome, Safari, and Brave (built on Chromium). None of them work in standard tabs but all of them work in incognito tabs. Do you have any idea why that would be? Does it have something to do with lack of https? I know that is my next step I need to setup. Thanks.

    – Sean

  • Show 1 more comments
1 Answer

This question was answered by @seanaye2:

SOLVED: I used certbot to automatically add an SSL certificate to my site. I also added the www.sevenlotus.co hostname in my DNS settings as I only had sevenlotus.co before. I’m not sure which of these fixed the problem but the site now functions as expected.

View the original comment

Have another answer? Share your knowledge.