我们的服务器今天突然掉线了。我无法登录,只是收到一条消息,说网络已关闭。
我使用POSTMAN查找更多其他信息。 POSTMAN返回502错误的网关错误。
服务器堆栈当前为:
-服务器操作系统-Ubuntu 16.04
-Web服务器-NGINX
服务器应用程序-Loopback.js和PM2
我已经用pm2 start all
重新启动了服务器应用程序,但这不能解决问题。
然后我尝试通过service nginx reload
重新启动nginx,结果导致
====验证org.freedesktop.systemd1.manage-units ===需要验证才能重新加载'nginx.service'。验证中 如:Ubuntu(someapp)密码: ====身份验证完成===
这也没有解决问题。
接下来,我尝试了sudo nginx
,导致出现以下消息:
nginx:[emerg] bind()到0.0.0.0:80失败(98:地址已经在 使用)nginx:[emerg] bind()到0.0.0.0:443失败(98:地址已经 nginx:[emerg] bind()到0.0.0.0:80失败(98:地址 已在使用)nginx:[emerg] bind()到0.0.0.0:443失败(98: 已使用的地址)nginx:[emerg] bind()到0.0.0.0:80失败 (98:地址已在使用中)nginx:[emerg] bind()为0.0.0.0:443 失败(98:地址已在使用中)nginx:[emerg] bind() 0.0.0.0:80失败(98:地址已在使用中)nginx:[emerg] bind()到0.0.0.0:443失败(98:地址已在使用中)nginx:[emerg] 将bind()设置为0.0.0.0:80失败(98:地址已在使用中)nginx: [emerg] bind()到0.0.0.0:443失败(98:地址已在使用中) nginx:[emerg]仍然无法绑定()
This帖子阐明了该问题,但我不确定如何从这一点着手。
我跑了grep -r listen /etc/nginx/*
得到了:
/etc/nginx/conf.d/default.conf: listen 80;
/etc/nginx/conf.d/default.conf: # proxy the PHP scripts to Apache listening on 127.0.0.1:80
/etc/nginx/conf.d/default.conf: # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
/etc/nginx/sites-available/default: listen 80; # managed by Certbot
/etc/nginx/sites-available/default: listen 443 ssl;
/etc/nginx/sites-available/default: listen 80; # managed by Certbot
/etc/nginx/sites-available/default: listen 443 ssl;
/etc/nginx/sites-available/default.bak: listen 443 ssl; # managed by Certbot
/etc/nginx/sites-available/default.bak: listen 443 ssl; # managed by Certbot
/etc/nginx/sites-available/default.bak: listen 80;
/etc/nginx/sites-available/default.bak: listen 80;
/etc/nginx/sites-available/default.80.bak: listen 80; # managed by Certbot
/etc/nginx/sites-available/default.80.bak: listen 80; # managed by Certbot
sudo netstat -tulpn
产生
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:29131 0.0.0.0:* LISTEN 2906/mdsd
tcp 0 0 127.0.0.1:587 0.0.0.0:* LISTEN 2084/master
tcp 0 0 0.0.0.0:25324 0.0.0.0:* LISTEN 89828/ruby
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 64005/nginx: master
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 29487/systemd-resol
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1520/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2084/master
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 64005/nginx: master
tcp6 0 0 ::1:587 :::* LISTEN 2084/master
tcp6 0 0 :::21 :::* LISTEN 1526/vsftpd
tcp6 0 0 :::22 :::* LISTEN 1520/sshd
tcp6 0 0 ::1:25 :::* LISTEN 2084/master
udp 0 0 127.0.0.53:53 0.0.0.0:* 29487/systemd-resol
udp 0 0 0.0.0.0:68 0.0.0.0:* 958/dhclient
udp 0 0 127.0.0.1:25224 0.0.0.0:* 89828/ruby
我环顾了
中列出的文件grep -R default_server / etc / nginx
它列出了3个不同的文件。
默认默认值。80.bakdefault.bak
默认文件应该有3个不同的版本吗?
我想验证nginx是否正在运行
nginx.service - nginx - high performance web server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2019-06-07 02:29:52 UTC; 12min ago
Docs: http://nginx.org/en/docs/
Process: 73013 ExecStop=/bin/kill -s TERM $MAINPID (code=exited, status=1/FAILURE)
Process: 63882 ExecReload=/bin/kill -s HUP $MAINPID (code=exited, status=0/SUCCESS)
Process: 78326 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS)
Main PID: 78334 (nginx)
Tasks: 2 (limit: 4029)
CGroup: /system.slice/nginx.service
├─78334 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
└─78337 nginx: worker process
Jun 07 02:29:52 some-server systemd[1]: Starting nginx - high performance web server...
Jun 07 02:29:52 some-server systemd[1]: nginx.service: Can't open PID file /var/run/nginx.pid (yet?) after start: No such fi
Jun 07 02:29:52 some-server systemd[1]: Started nginx - high performance web server.
这是less /var/log/nginx/error.log
2019/06/07 02:51:39 [error] 78337#78337: *34 connect() failed (111: Connection refused) while connecting to upstream,
client: 201.92.190.140, server: someunion.com, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:3000/",
host: "xx.xxx.xxx.xx:80"
这是sudo lsof -i TCP:80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx 91299 root 6u IPv4 77726277 0t0 TCP *:http (LISTEN)
nginx 91301 nginx 6u IPv4 77726277 0t0 TCP *:http (LISTEN)