nginx: [error] open() "/usr/local/nginx/logs/nginx.pid" failed (2: No such file or directory)

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;
    }
}
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容