Score:0

Pm2 and Nginx wont communicate and SSL handshake failed

cn flag

Hello I am fairly new to ubuntu and pm2 and Nginx but have been having this inconsistent problem for a few days and have no clue how to fix it as google doesn't tell me anything. Keep it me it used to work and now it dosent.

So in short I have set up Nginx with the config below.

server {

         root /home/ubuntu/apps/bachelor-app/client/build;

        # Add index.php to the list if you are using PHP
        index index.html index.htm index.nginx-debian.html;

        server_name vizdatathesis.com www.vizdatathesis.com;

        location / {
                        try_files $uri /index.html;
                        }

         location /api {
                     proxy_pass http://localhost:3005;
                        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 ipv6only=on; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/vizdatathesis.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/vizdatathesis.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.vizdatathesis.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    if ($host = vizdatathesis.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot
        listen 80;
        listen [::]:80;
        server_name vizdatathesis.com www.vizdatathesis.com;
    return 404; # managed by Certbot
}

Pm2 logs return

Error: listen EADDRINUSE: address already in use :::3005
    at Server.setupListenHandle [as _listen2] (node:net:1372:16)
    at listenInCluster (node:net:1420:12)
    at Server.listen (node:net:1508:7)
    at Function.listen (/home/ubuntu/apps/bachelor-app/Server/node_modules/express/lib/application.js:618:24)
    at Object.<anonymous> (/home/ubuntu/apps/bachelor-app/Server/Server.js:239:5)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Object.<anonymous> (/usr/lib/node_modules/pm2/lib/ProcessContainerFork.js:33:23) {
  code: 'EADDRINUSE',
  errno: -98,
  syscall: 'listen',
  address: '::',
  port: 3005
}

However it tells me everything is up and running.

┌─────┬────────────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id  │ name           │ namespace   │ version │ mode    │ pid      │ uptime │ ↺    │ status    │ cpu      │ mem      │ user     │ watching │
├─────┼────────────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 0   │ dataviz-app    │ default     │ 1.0.0   │ fork    │ 25325    │ 11m    │ 1    │ online    │ 0%       │ 53.3mb   │ ubuntu   │ enabled  │
└─────┴────────────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘

Nginx gives me this error:

2022/05/18 16:34:53 [crit] 25410#25410: *1209 SSL_do_handshake() failed (SSL: error:0A00006C:SSL routines::bad key share) while SSL handshaking, client: x.x.x.x, server: 0.0.0.0:443
2022/05/18 18:11:32 [notice] 1107#1107: signal process started

I am overwhelmed with errors at this points and have no clue where the root of the problem is. I have tried to restart both pm2 and nginx but it didnt help. The sites shows the nginx but gets net::ERR_CONNECTION_REFUSED when trying to reach the server.

Tim avatar
gp flag
Tim
I would first look into the Nginx error. "Bad Key Share" seems to be the main message. Do some research, follow another tutorial to set up https. "Address already in use" often means you're trying to use a port that's already in use, starting a service twice for example.
Running moments avatar
cn flag
`2022/05/18 18:11:32 [notice] 1107#1107: signal process started` Have you heard about this error before @Tim
Tim avatar
gp flag
Tim
That's a notice telling you part of Nginx started. Probably not relevant to your current issue. My Nginx instance says the same thing.
Running moments avatar
cn flag
Now I get another error code. It tells me `2022/05/18 18:06:22 [crit] 26046#26046: *1305 SSL_do_handshake() failed (SSL: error:0A000126:SSL routines::unexpected eof while reading) while SSL handshaking, client: 139.99.61.171, server: 0.0.0.0:443`
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.