日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 综合教程 >内容正文

综合教程

Nginx反向代理报504超时错误

發布時間:2023/12/31 综合教程 31 生活家
生活随笔 收集整理的這篇文章主要介紹了 Nginx反向代理报504超时错误 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

nginx+tomcat

后端為tomcat,nginx代理報504超時錯誤。

問題描述:

#錯誤
1.198.17.123--[06/Jul/2018:01:48:57+0000]"POST/mapbj3/getticketHTTP/1.1"504537"https://XXXXXXXXXX.com/walkcode3/index.html?openId=oB6UW0cF3Z_dnYXnz4tG4OFt7Rt0""Mozilla/5.0(Linux;Android8.1;PACM00Build/O11019;wv)AppleWebKit/537.36(KHTML,likeGecko)Version/4.0Chrome/53.0.2785.143Crosswalk/24.53.595.0XWEB/155MMWEBSDK/19MobileSafari/537.36MicroMessenger/6.6.6.1300(0x26060638)NetType/WIFILanguage/zh_CNMicroMessenger/6.6.6.1300(0x26060638)NetType/WIFILanguage/zh_CNminiProgram""-"
2018/07/0601:48:57[error]6#6:*2573upstreamtimedout(110:Connectiontimedout)whileconnectingtoupstream,client:1.198.17.123,server:,request:"POST/mapbj3/getticketHTTP/1.1",upstream:"http://123.149.236.180:8022/mapbj3//getticket",host:"XXXXXXXX.com",referrer:"https://XXXXXXX.com/walkcode3/index.html?openId=oB6UW0cF3Z_dnYXnz4tG4OFt7Rt0"

1、項目本地訪問沒問題,通過nginx訪問報504錯誤;

2、重啟nginx后正常,反復發生,其它項目代理沒有問題;

3、搜索了一大推”NGINX 504 Gateway Time-out tomcat”,都是與php有關的,而默認優化的就是php配置的;

問題處理:

修改/etc/nginx/nginx.conf,添加如下信息

#cat/etc/nginx/nginx.conf
usernginx;
worker_processes1;

error_log/var/log/nginx/error.logwarn;
pid/var/run/nginx.pid;


events{
worker_connections1024;
}


http{
include/etc/nginx/mime.types;
default_typeapplication/octet-stream;

log_formatmain'$remote_addr-$remote_user[$time_local]"$request"'
'$status$body_bytes_sent"$http_referer"'
'"$http_user_agent""$http_x_forwarded_for"';

access_log/var/log/nginx/access.logmain;

sendfileon;
#tcp_nopushon;

keepalive_timeout65;

#gzipon;

include/etc/nginx/conf.d/*.conf;
#用于tomcat反向代理,解決nginx504錯誤
proxy_connect_timeout300;
proxy_send_timeout300;
proxy_read_timeout300;
proxy_buffer_size16k;
proxy_buffers464k;
proxy_busy_buffers_size128k;
proxy_temp_file_write_size128k;
#ps:以timeout結尾配置項時間要配置大點
}

nginx+php(未驗證)

問題如上,問題處理添加如下內容

usernginx;
worker_processes1;

error_log/var/log/nginx/error.logwarn;
pid/var/run/nginx.pid;


events{
worker_connections1024;
}


http{
include/etc/nginx/mime.types;
default_typeapplication/octet-stream;

log_formatmain'$remote_addr-$remote_user[$time_local]"$request"'
'$status$body_bytes_sent"$http_referer"'
'"$http_user_agent""$http_x_forwarded_for"';

access_log/var/log/nginx/access.logmain;

sendfileon;
#tcp_nopushon;

keepalive_timeout65;

#gzipon;

include/etc/nginx/conf.d/*.conf;
#用于php反向代理,解決nginx504錯誤
#以fastcgi_*配置項是php用的
fastcgi_connect_timeout1000;
fastcgi_send_timeout1000;
fastcgi_read_timeout1000;
fastcgi_buffer_size64k;
fastcgi_buffers8128k;
fastcgi_busy_buffers_size128k;
fastcgi_temp_file_write_size128k;
fastcgi_intercept_errorson;
}

參考文檔

https://blog.csdn.net/lcj_star/article/details/76672748https://www.iyunv.com/thread-319236-1-1.html

nginx+tomcat

后端為tomcat,nginx代理報504超時錯誤。

問題描述:







Default

1
2
3

#錯誤
1.198.17.123--[06/Jul/2018:01:48:57+0000]"POST/mapbj3/getticketHTTP/1.1"504537"https://XXXXXXXXXX.com/walkcode3/index.html?openId=oB6UW0cF3Z_dnYXnz4tG4OFt7Rt0""Mozilla/5.0(Linux;Android8.1;PACM00Build/O11019;wv)AppleWebKit/537.36(KHTML,likeGecko)Version/4.0Chrome/53.0.2785.143Crosswalk/24.53.595.0XWEB/155MMWEBSDK/19MobileSafari/537.36MicroMessenger/6.6.6.1300(0x26060638)NetType/WIFILanguage/zh_CNMicroMessenger/6.6.6.1300(0x26060638)NetType/WIFILanguage/zh_CNminiProgram""-"
2018/07/0601:48:57[error]6#6:*2573upstreamtimedout(110:Connectiontimedout)whileconnectingtoupstream,client:1.198.17.123,server:,request:"POST/mapbj3/getticketHTTP/1.1",upstream:"http://123.149.236.180:8022/mapbj3//getticket",host:"XXXXXXXX.com",referrer:"https://XXXXXXX.com/walkcode3/index.html?openId=oB6UW0cF3Z_dnYXnz4tG4OFt7Rt0"

1、項目本地訪問沒問題,通過nginx訪問報504錯誤;

2、重啟nginx后正常,反復發生,其它項目代理沒有問題;

3、搜索了一大推”NGINX 504 Gateway Time-out tomcat”,都是與php有關的,而默認優化的就是php配置的;

問題處理:

修改/etc/nginx/nginx.conf,添加如下信息






Default

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41

#cat/etc/nginx/nginx.conf
usernginx;
worker_processes1;

error_log/var/log/nginx/error.logwarn;
pid/var/run/nginx.pid;


events{
worker_connections1024;
}


http{
include/etc/nginx/mime.types;
default_typeapplication/octet-stream;

log_formatmain'$remote_addr-$remote_user[$time_local]"$request"'
'$status$body_bytes_sent"$http_referer"'
'"$http_user_agent""$http_x_forwarded_for"';

access_log/var/log/nginx/access.logmain;

sendfileon;
#tcp_nopushon;

keepalive_timeout65;

#gzipon;

include/etc/nginx/conf.d/*.conf;
#用于tomcat反向代理,解決nginx504錯誤
proxy_connect_timeout300;
proxy_send_timeout300;
proxy_read_timeout300;
proxy_buffer_size16k;
proxy_buffers464k;
proxy_busy_buffers_size128k;
proxy_temp_file_write_size128k;
#ps:以timeout結尾配置項時間要配置大點
}

nginx+php(未驗證)

問題如上,問題處理添加如下內容






Default

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41

usernginx;
worker_processes1;

error_log/var/log/nginx/error.logwarn;
pid/var/run/nginx.pid;


events{
worker_connections1024;
}


http{
include/etc/nginx/mime.types;
default_typeapplication/octet-stream;

log_formatmain'$remote_addr-$remote_user[$time_local]"$request"'
'$status$body_bytes_sent"$http_referer"'
'"$http_user_agent""$http_x_forwarded_for"';

access_log/var/log/nginx/access.logmain;

sendfileon;
#tcp_nopushon;

keepalive_timeout65;

#gzipon;

include/etc/nginx/conf.d/*.conf;
#用于php反向代理,解決nginx504錯誤
#以fastcgi_*配置項是php用的
fastcgi_connect_timeout1000;
fastcgi_send_timeout1000;
fastcgi_read_timeout1000;
fastcgi_buffer_size64k;
fastcgi_buffers8128k;
fastcgi_busy_buffers_size128k;
fastcgi_temp_file_write_size128k;
fastcgi_intercept_errorson;
}

參考文檔

https://blog.csdn.net/lcj_star/article/details/76672748https://www.iyunv.com/thread-319236-1-1.html

總結

以上是生活随笔為你收集整理的Nginx反向代理报504超时错误的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。