操作
首先nginx不是自己部署,要先啟動一下
docker start nginx
發現列印出了nginx 但是docker ps 發現nginx還是啟動失敗
於是準備查看日誌
docker logs -f nginx
報了一堆錯誤,也不知道是什麼時候打的日誌,後來解決之後猜測是因為設定檔為空的原因,因為沒有找到event模組
所以先來看看nginx的容器資訊
docker inspect nginx
找到掛載資訊了,可以看看配置文件,發現/usr/nginx/conf 裡面沒有配置文件,這個時候就應該找到了問題;可是維運同學在查詢問題的時候創建了一個空的nginx.conf,我沒有打開配置文件
後來在老大的提醒下開啟了設定檔發現是空的,然後就對設定檔進行了修改
先找了一個預設的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 發現可以啟動了
接下來增加正確的jira配置
location / { proxy_pass http://192.168.1.111:8080; proxy_redirect off; proxy_set_header Host $host:$server_port; ##重点在$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; }
進入容器檢測一下設定檔是否有問題
docker exec -it 容器id /bin/bash
nginx路徑尋找find / -name nginx
./nginx/sbin/nginx -t
偵測發現少了一個}
:set nu
找到具體行,然後修正
ctrl +D // 退出容器
啟動nginx
docker restart nginx
以上是nginx啟動失敗如何解決的詳細內容。更多資訊請關注PHP中文網其他相關文章!

NGINX适合高并发和低资源消耗场景,Apache适用于需要复杂配置和功能扩展的场景。1.NGINX以高性能处理大量并发连接著称。2.Apache以稳定性和丰富模块支持见长。选择时需根据具体需求决定。

NGINXisessentialformodernwebapplicationsduetoitsrolesasareverseproxy,loadbalancer,andwebserver,offeringhighperformanceandscalability.1)Itactsasareverseproxy,enhancingsecurityandperformancebycachingandloadbalancing.2)NGINXsupportsvariousloadbalancingm

通過Nginx配置SSL/TLS來確保網站安全,需要以下步驟:1.創建基本配置,指定SSL證書和私鑰;2.優化配置,啟用HTTP/2和OCSPStapling;3.調試常見錯誤,如證書路徑和加密套件問題;4.應用性能優化建議,如使用Let'sEncrypt和會話復用。

Nginx是高性能的HTTP和反向代理服務器,擅長處理高並發連接。 1)基本配置:監聽端口並提供靜態文件服務。 2)高級配置:實現反向代理和負載均衡。 3)調試技巧:檢查錯誤日誌和測試配置文件。 4)性能優化:啟用Gzip壓縮和調整緩存策略。

Nginx缓存可以通过以下步骤显著提升网站性能:1)定义缓存区和设置缓存路径;2)配置缓存有效期;3)根据不同内容设置不同的缓存策略;4)优化缓存存储和负载均衡;5)监控和调试缓存效果。通过这些方法,Nginx缓存能减少后端服务器压力,提升响应速度和用户体验。

使用DockerCompose可以簡化Nginx的部署和管理,通過DockerSwarm或Kubernetes進行擴展是常見的做法。 1)使用DockerCompose定義和運行Nginx容器,2)通過DockerSwarm或Kubernetes實現集群管理和自動擴展。

Nginx的高級配置可以通過服務器塊和反向代理實現:1.服務器塊允許在一個實例中運行多個網站,每個塊獨立配置。 2.反向代理將請求轉發到後端服務器,實現負載均衡和緩存加速。

Nginx性能調優可以通過調整worker進程數、連接池大小、啟用Gzip壓縮和HTTP/2協議、使用緩存和負載均衡來實現。 1.調整worker進程數和連接池大小:worker_processesauto;events{worker_connections1024;}。 2.啟用Gzip壓縮和HTTP/2協議:http{gzipon;server{listen443sslhttp2;}}。 3.使用緩存優化:http{proxy_cache_path/path/to/cachelevels=1:2k


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章

熱工具

MinGW - Minimalist GNU for Windows
這個專案正在遷移到osdn.net/projects/mingw的過程中,你可以繼續在那裡關注我們。 MinGW:GNU編譯器集合(GCC)的本機Windows移植版本,可自由分發的導入函式庫和用於建置本機Windows應用程式的頭檔;包括對MSVC執行時間的擴展,以支援C99功能。 MinGW的所有軟體都可以在64位元Windows平台上運作。

SublimeText3 Linux新版
SublimeText3 Linux最新版

DVWA
Damn Vulnerable Web App (DVWA) 是一個PHP/MySQL的Web應用程序,非常容易受到攻擊。它的主要目標是成為安全專業人員在合法環境中測試自己的技能和工具的輔助工具,幫助Web開發人員更好地理解保護網路應用程式的過程,並幫助教師/學生在課堂環境中教授/學習Web應用程式安全性。 DVWA的目標是透過簡單直接的介面練習一些最常見的Web漏洞,難度各不相同。請注意,該軟體中

Atom編輯器mac版下載
最受歡迎的的開源編輯器

Safe Exam Browser
Safe Exam Browser是一個安全的瀏覽器環境,安全地進行線上考試。該軟體將任何電腦變成一個安全的工作站。它控制對任何實用工具的訪問,並防止學生使用未經授權的資源。