P
P
pazoozoo2018-03-31 15:38:20
Nginx
pazoozoo, 2018-03-31 15:38:20

Node.js Digitalocean Ubuntu NGINX net::ERR_CONNECTION_TIMED_OUT what could be the problem?

Application on MEAN2-stack throws an error:


GET https://xx.xx.xx.xx:3000/api/check-email?email=tes... net::ERR_CONNECTION_TIMED_OUT

Also request:

curl https://xx.xx.xx.xx:3000/api/check-email?email=tes...

gives an error message:

curl: (35) gnutls_handshake() failed: An unexpected TLS packet was received.

Although the same request that starts with http will work fine:

curl xx.xx.xx.xx:3000/api/[email protected]

Everything works fine on the local server, but problems start on the production server.
Websockets are not used.
Base Url on frontend: ip and port on nodejs:
private baseUrl = 'https://xx.xx.xx.xx:3000/api/';
...
app.use( '/api', routesApi );
...
app.listen( 3000, 'xx.xx.xx.xx', () => {
  console.log( 'Server is running' );
} );

My nginx settings:
server {

    server_name helperra.com www.helperra.com;

    location / {
        root   /helperra/client/dist;
        try_files $uri $uri/ @node;
    }

    location @node {

        proxy_pass http://xx.xx.xx.xx:3000;
        proxy_redirect off;

        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;
    }

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/helperra.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/helperra.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
    if ($host = www.helperra.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

    if ($host = helperra.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

    listen 80;

    server_name helperra.com www.helperra.com;
    return 404; # managed by Certbot
}

This is my first time setting up a server on Ubuntu and my first time dealing with nginx.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
pazoozoo, 2018-03-31
@pazoozoo

After I removed the host on the front and back, everything worked.

app.listen( port, () => {
  console.log( 'Server is running' );
} );

I spent two days to understand once again - it's better not to hardcode!

D
Dimonchik, 2018-03-31
@dimonchik2013

look at the nginx logs, apparently it doesn’t reach the upstream proxy, httP is in the same place, and you redirect everything to httpS

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question