記錄一次nginx啟動(dòng)失敗的解決過程
周日領(lǐng)導(dǎo)說docker nginx起不來了,導(dǎo)致jira域名映射失敗,記錄一下解決過程
操作
首先nginx不是自己部署,要先啟動(dòng)一下
docker start nginx
發(fā)現(xiàn)打印出了nginx 但是 docker ps 發(fā)現(xiàn) nginx還是啟動(dòng)失敗
于是準(zhǔn)備查看日志
docker logs -f nginx
報(bào)了一堆錯(cuò)誤,也不知道是什么時(shí)候打的日志,后來解決之后猜測(cè)是因?yàn)榕渲梦募榭盏脑颍驗(yàn)闆]有找到event模塊
所以首先看一下nginx的容器信息
docker inspect nginx
找到掛載信息了,可以看看配置文件,發(fā)現(xiàn) /usr/nginx/conf 里面沒有配置文件,這個(gè)時(shí)候就應(yīng)該找到了問題;可是運(yùn)維同學(xué)在查詢問題的時(shí)候創(chuàng)建了一個(gè)空的nginx.conf,我沒有打開配置文件
后來在老大的提醒下打開了配置文件發(fā)現(xiàn)是空的,然后就對(duì)配置文件進(jìn)行了修改
先找了一個(gè)默認(rèn)的nginx.conf的配置
#user nobody; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' # '$status $body_bytes_sent "$http_referer" ' # '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; server { listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { root html; index index.html index.htm; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { # proxy the PHP scripts to Apache listening on 127.0.0.1:80 #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; # deny access to .htaccess files, if Apache's document root # concurs with nginx's one #location ~ /\.ht { # deny all; } # another virtual host using mix of IP-, name-, and port-based configuration # #server { # listen 8000; # listen somename:8080; # server_name somename alias another.alias; # location / { # root html; # index index.html index.htm; # } #} # HTTPS server # listen 443 ssl; # server_name localhost; # ssl_certificate cert.pem; # ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m; # ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5; # ssl_prefer_server_ciphers on;
然后docker start nginx 發(fā)現(xiàn)可以啟動(dòng)了
接下來增加正確的jira配置
location / { proxy_pass http://192.168.1.111:8080; proxy_redirect off; proxy_set_header Host $host:$server_port; ##重點(diǎn)在$server_port proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_max_temp_file_size 0; proxy_connect_timeout 90; proxy_send_timeout 90; proxy_read_timeout 90; proxy_buffer_size 4k; proxy_buffers 4 32k; proxy_busy_buffers_size 64k; proxy_hide_header Vary; proxy_set_header Accept-Encoding ''; proxy_set_header Referer $http_referer; proxy_set_header Cookie $http_cookie; }
進(jìn)入容器檢測(cè)一下配置文件是否有問題
docker exec -it 容器id /bin/bash
nginx路徑尋找 find / -name nginx
./nginx/sbin/nginx -t
檢測(cè)發(fā)現(xiàn)少了一個(gè)}
:set nu
找到具體行,然后修復(fù)
ctrl +D // 退出容器
啟動(dòng)nginx
docker restart nginx
結(jié)果
雖然解決的很慢 但是還是解決了問題,nginx單點(diǎn)也是有問題的,后期打算切換到多活的nginx,然后備份相關(guān)nginx文件
到此這篇關(guān)于記錄一次nginx啟動(dòng)失敗的解決過程的文章就介紹到這了,更多相關(guān)nginx啟動(dòng)失敗內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Nginx(PHP/fastcgi)的PATH_INFO問題
PATH_INFO是一個(gè)CGI 1.1的標(biāo)準(zhǔn),經(jīng)常用來做為傳參載體. 比如, 我們可以使用PATH_INFO來代替Rewrite來實(shí)現(xiàn)偽靜態(tài)頁面, 另外不少PHP框架也使用PATH_INFO來作為路由載體.2011-08-08Nginx配置HTTP強(qiáng)制跳轉(zhuǎn)到HTTPS的解決辦法
這篇文章主要給大家介紹了關(guān)于Nginx配置HTTP強(qiáng)制跳轉(zhuǎn)到HTTPS的解決辦法,當(dāng)Nginx配置https后通常需要將用戶http請(qǐng)求強(qiáng)制跳轉(zhuǎn)到https,需要的朋友可以參考下2023-08-08nginx中使用nginx-http-concat模塊合并靜態(tài)資源文件
這篇文章主要介紹了nginx中使用nginx-http-concat模塊合并靜態(tài)資源文件,用以加速網(wǎng)站的CSS、JS等靜態(tài)資源載入速度,需要的朋友可以參考下2014-06-06nginx配置proxy_pass代理轉(zhuǎn)發(fā)時(shí)報(bào)404問題
這篇文章主要介紹了nginx配置proxy_pass代理轉(zhuǎn)發(fā)時(shí)報(bào)404問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2024-01-01nginx 流量控制以及訪問控制的實(shí)現(xiàn)
這篇文章主要介紹了nginx 流量控制以及訪問控制的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-08-08