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.