您好,我对 ubuntu、pm2 和 Nginx 还不太熟悉,但几天来一直遇到这个不一致的问题,不知道如何解决,因为谷歌没有告诉我任何事情。记住,它以前可以工作,但现在不行了。
简而言之,我使用下面的配置设置了 Nginx。
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 日志返回
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
}
但它告诉我一切正常。
┌─────┬────────────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ 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 给出了这个错误:
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
此时我被错误弄得不知所措,不知道问题的根源在哪里。我尝试重新启动 pm2 和 nginx,但没有帮助。网站显示 nginx,但在尝试访问服务器时出现 net::ERR_CONNECTION_REFUSED。