Nginx 502錯(cuò)誤兩種解決方案介紹
我們?cè)谑褂?a >Nginx的時(shí)候有不少問題出現(xiàn),首先我們就來解決下Nginx 502錯(cuò)誤的問題。定義Nginx 404 502錯(cuò)誤提示頁(yè)面,直接配置Nginx 502錯(cuò)誤,找了很多資料,最終沒能實(shí)現(xiàn)。下面用另一個(gè)方法實(shí)現(xiàn).
方法一:在Nginx.conf配置文件里加上以下紅色代碼
- erver
- {
- listen 80;
- server_name www.tt.com;
- location / {
- proxy_pass http://week;
- proxy_set_header Host $host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- if (!-f $request_filename) {
- proxy_pass http://127.0.0.1:8888;
- }
- }
17.0.0.1:8888配置如下
- erver
- {
- listen 8888;
- server_name www.tt.com;
- location / {
- root /root;
- index index.html;
- error_page 500 502 404 /404.html;
- }
- }
需要維護(hù)的時(shí)候,只需要重啟Nginx服務(wù)。
- kill -HUP 'cat logs/ nginx .pid'
方法二:?jiǎn)?**建一個(gè)testnginx.conf文件
- #user nobody;
- worker_processes 1;
- pid logs/nginx.pid;
- events {
- use epoll;
- worker_connections 50000;
- }
- http {
- include mime.types;
- default_type application/octet-stream;
- sendfile on;
- server
- {
- listen 80;
- server_name www.tt.com;
- location / {
- root /root;
- index index.html;
- error_page 500 502 404 /404.html;
- }
- }
- }
維護(hù)時(shí)只需把Nginx 502錯(cuò)誤停止,從新啟用新的配置文件
- killall -9 nginx
- nginx -c ../conf/testnginx.conf
以上就是對(duì)Nginx 502錯(cuò)誤的詳細(xì)介紹希望大家有所幫助。
【編輯推薦】