nginx: [error] open() "/usr/local/nginx/logs/nginx.pid" failed (2: No such file or directory)
执行这个
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
如果执行了报错
[root@nginx-master ~]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()
报了以上错,查了好久的资料,说什么端口被占用,杀死进程什么的,但是压根都看不到进程和端口占用,最后查出真相是nginx.conf配置问题,把下面这段配置删除就可以了
http {
# ...
map $http_upgrade $connection_upgrade {
default Upgrade;
'' close;
}
server {
# websockets
location / {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
# 这里将允许您在 Rancher UI 中打开命令行窗口时,窗口可以保留最多15分钟。没有这个参数时,默认值为1分钟,一分钟后在Rancher中的shell会自动关闭。
proxy_read_timeout 900s;
proxy_buffering off;
}
}
}
修改后的配置
worker_processes 4;
worker_rlimit_nofile 40000;
events {
worker_connections 8192;
}
stream {
upstream rancher_servers_http {
least_conn;
server 192.168.30.80:8080 max_fails=3 fail_timeout=5s;
#server 192.168.30.51:80 max_fails=3 fail_timeout=5s;
}
server {
listen 80;
proxy_pass rancher_servers_http;
}
upstream rancher_servers_https {
least_conn;
server 192.168.30.80:8443 max_fails=3 fail_timeout=5s;
#server 192.168.30.51:443 max_fails=3 fail_timeout=5s;
}
server {
listen 443;
proxy_pass rancher_servers_https;
}
}
网友评论