浏览器debug 调试一打开 Nginx 就 504 Gateway Time-out

简介: 浏览器debug 调试一打开 Nginx 就 504 Gateway Time-out

http {

keepalive_timeout 1800s; #指定 KeepAlive 的超时时间(timeout)。指定每个 TCP 连接最多可以保持多长时间。Nginx 的默认值是 75 秒,有些浏览器最多只保持 60 秒,所以可以设定为 60 秒。若将它设置为 0,就禁止了 keepalive 连接。

proxy_connect_timeout 1800s; #nginx跟后端服务器连接超时时间(代理连接超时)

proxy_send_timeout 1800s; #后端服务器数据回传时间(代理发送超时)

proxy_read_timeout 1800s; #连接成功后,后端服务器响应时间(代理接收超时)

fastcgi_connect_timeout 1800s; #指定nginx与后端fastcgi server连接超时时间

fastcgi_send_timeout 1800s; #指定nginx向后端传送请求超时时间(指已完成两次握手后向fastcgi传送请求超时时间)

fastcgi_read_timeout 1800s; #指定nginx向后端传送响应超时时间(指已完成两次握手后向fastcgi传送响应超时时间)


}


15.png

15.png


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" $request_time $upstream_response_time ';
    access_log  logs/access.log  main;
    client_header_buffer_size 64k;
    large_client_header_buffers 8 64k;
    client_max_body_size 200m;
    client_body_buffer_size 8M;
#清理缓存
    sendfile off;
#    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 1200;
    proxy_connect_timeout 50000;
    #proxy_connect_timeout 500;
    proxy_read_timeout 60000;
    #proxy_send_timeout 500;
    proxy_send_timeout 50000;
    #fastcgi_buffers 80 128k;
fastcgi_connect_timeout 30000;
fastcgi_send_timeout 30000;
fastcgi_read_timeout 30000;
    send_timeout 6000;
    proxy_buffer_size 96k;
    #proxy_buffer_size 16k;
    proxy_buffers 4 64k;
    #proxy_buffers 4 64k;
    proxy_busy_buffers_size 128k;
    proxy_temp_file_write_size 128k;
    proxy_temp_path /data/nginx/proxy_temp;
    proxy_cache_path /data/nginx/proxy_cache levels=1:2 keys_zone=content:20m inactive=1d max_size=100m;
    proxy_cache_bypass $http_secret_header;
    gzip  on;
    gzip_min_length 1k;
    gzip_buffers 4 16k;
    gzip_http_version 1.0;
    gzip_comp_level 2;
    gzip_types text/plain application/x-javascript text/css application/xml application/javascript;


16.png


最重要的六条配置:


proxy_connect_timeout 1800s; #nginx跟后端服务器连接超时时间(代理连接超时)

proxy_send_timeout 1800s; #后端服务器数据回传时间(代理发送超时)

proxy_read_timeout 1800s; #连接成功后,后端服务器响应时间(代理接收超时)

fastcgi_connect_timeout 1800s; #指定nginx与后端fastcgi server连接超时时间

fastcgi_send_timeout 1800s; #指定nginx向后端传送请求超时时间(指已完成两次握手后向fastcgi传送请求超时时间)

fastcgi_read_timeout 1800s; #指定nginx向后端传送响应超时时间(指已完成两次握手后向fastcgi传送响应超时时间)


目录
相关文章
|
负载均衡 应用服务中间件 API
Nginx、Kong、Apisix、Gateway网关比较
Nginx、Kong、Apisix、Gateway网关比较
6418 1
Nginx、Kong、Apisix、Gateway网关比较
|
前端开发 应用服务中间件 API
比Nginx更好用的Gateway!
比Nginx更好用的Gateway!
376 1
比Nginx更好用的Gateway!
|
应用服务中间件 网络安全 nginx
百度搜索:蓝易云【nginx502 Bad Gateway错误解决办法】
请注意,解决502错误可能涉及到具体的网络架构和配置,因此以上办法仅供参考。如果问题仍然存在,建议根据具体情况深入分析并检查相关配置和服务器状态。同时,保持Nginx和上游服务器的版本为最新也是一个良好的实践,以获取更好的稳定性和性能。
568 2
|
应用服务中间件 nginx
nginx 504 Gateway Time-out
nginx 504 Gateway Time-out
2471 0
|
开发框架 Java .NET
线上debug&gateway自定义路由规则
【10月更文挑战第20天】本文介绍了线上调试和网关自定义路由规则的配置方法。线上调试部分涵盖日志记录、远程调试等内容,包括如何设置详细的日志级别、添加自定义日志信息以及使用ELK堆栈进行日志分析。网关自定义路由规则部分则讲解了Spring Cloud Gateway和Kong中基于路径、请求头、请求参数等条件的路由配置方法。
414 1
|
Java 应用服务中间件 nginx
【Azure Spring Apps】Spring App部署上云遇见 502 Bad Gateway nginx
在部署Azure Spring App后,用户遇到502 Bad Gateway错误,问题源于Nginx。解决方案是检查并关闭Spring App的ingress-to-app TLS配置,因为若未启用HTTPS访问,Nginx通过HTTPS访问应用会导致此错误。
428 2
|
Java 应用服务中间件 nginx
【Azure Spring Apps】Spring App部署上云遇见 502 Bad Gateway nginx
【Azure Spring Apps】Spring App部署上云遇见 502 Bad Gateway nginx
271 0
|
Java 应用服务中间件 nginx
一文读懂:Nginx 和Gateway
一文读懂:Nginx 和Gateway
1898 1
|
前端开发 Java 应用服务中间件
Springboot解决跨域问题方案总结(包括Nginx,Gateway网关等)
Springboot解决跨域问题方案总结(包括Nginx,Gateway网关等)