nginx: [error] open() "/usr/local/nginx/logs/nginx.pid" failed (2: No such file or directory)
執(zhí)行這個(gè)
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
如果執(zhí)行了報(bào)錯(cuò)
[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()
報(bào)了以上錯(cuò),查了好久的資料,說什么端口被占用,殺死進(jìn)程什么的,但是壓根都看不到進(jìn)程和端口占用,最后查出真相是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 中打開命令行窗口時(shí),窗口可以保留最多15分鐘。沒有這個(gè)參數(shù)時(shí),默認(rèn)值為1分鐘,一分鐘后在Rancher中的shell會(huì)自動(dòng)關(guān)閉。
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;
}
}