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后正常,反復(fù)發(fā)生,其它項目代理沒有問題;
3、搜索了一大推”NGINX 504 Gateway Time-out tomcat”,都是與php有關(guān)的,而默認優(yōu)化的就是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結(jié)尾配置項時間要配置大點
}
nginx+php(未驗證)
問題如上,問題處理添加如下內(nèi)容
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 |
#錯誤 |
1、項目本地訪問沒問題,通過nginx訪問報504錯誤;
2、重啟nginx后正常,反復(fù)發(fā)生,其它項目代理沒有問題;
3、搜索了一大推”NGINX 504 Gateway Time-out tomcat”,都是與php有關(guān)的,而默認優(yōu)化的就是php配置的;
問題處理:
修改/etc/nginx/nginx.conf,添加如下信息
Default
|
1 |
#cat/etc/nginx/nginx.conf |
nginx+php(未驗證)
問題如上,問題處理添加如下內(nèi)容
Default
|
1 |
usernginx; |
參考文檔
https://blog.csdn.net/lcj_star/article/details/76672748https://www.iyunv.com/thread-319236-1-1.html
總結(jié)
以上是生活随笔為你收集整理的Nginx反向代理报504超时错误的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 根据传递函数仿真模拟滤波器的波特图(持续
- 下一篇: 多项式相乘