尝试通过 nginx 反向代理注销时出现 502 错误网关

尝试通过 nginx 反向代理注销时出现 502 错误网关

当我尝试注销我的 php 应用程序时,nginx 反向代理抛出 502 错误网关错误。

错误日志显示此错误:

[error] 20284#0: *1 upstream sent too big header while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "GET /logout HTTP/1.1", upstream: "http://10.0.10.123:80/logout",

nginx 配置如下

user  nginx;
worker_processes  8;
worker_rlimit_nofile 200000;

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


events {
worker_connections  200000;
use epoll;
}

http {

#Basic settings

keepalive_timeout  15;
# Number of requests a client can make over the keep-alive connection. This is set high for testing.
keepalive_requests 100;
include       /etc/nginx/mime.types;
default_type  application/octet-stream;
include /etc/nginx/conf.d/*.conf;

#Log settings
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  /var/log/nginx/access.log  main;
add_header X-Content-Type-Options nosniff;

#gzip settings
gzip  on;
gzip_comp_level 6;
gzip_disable "msie6";
gzip_min_length 150;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/xml text/css application/json application/javascript;
gzip_vary on;

#Security Settings
server_tokens off;

sendfile     on;
tcp_nopush   on;
tcp_nodelay  on;
open_file_cache            max=2000  inactive=10s;
open_file_cache_valid      15s;
open_file_cache_min_uses   2;
open_file_cache_errors     on;
reset_timedout_connection  on;
client_body_timeout        10;
client_header_timeout 10;
send_timeout               10;
types_hash_max_size  2048;
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=two:4m max_size=100M inactive=30m;

large_client_header_buffers  16 24k;
client_max_body_size 12m;
client_body_buffer_size 24k;
client_header_buffer_size 16k;
limit_conn_zone $binary_remote_addr zone=addr:10m;
limit_req_zone $binary_remote_addr zone=one:10m rate=5r/s;
limit_conn addr 2;
limit_req zone=one burst=10;

}

TCP 转储日志

21:00:41.739886 IP 10.0.10.126.9506 > 10.0.10.123.http: Flags [.], ack 1, win 115, options [nop,nop,TS val 17409473 ecr 18227931], length 0
21:00:41.739910 IP 10.0.10.126.9506 > 10.0.10.123.http: Flags [P.], seq 1:1244, ack 1, win 115, options [nop,nop,TS val 17409473 ecr 18227931], length 1243
21:00:41.740050 IP 10.0.10.123.http > 10.0.10.126.9506: Flags [.], ack 1244, win 125, options [nop,nop,TS val 18227931 ecr 17409473], length 0
21:00:41.758454 IP 10.0.10.123.http > 10.0.10.126.9506: Flags [.], seq 1:2897, ack 1244, win 125, options [nop,nop,TS val 18227936 ecr 17409473], length 2896
21:00:41.758482 IP 10.0.10.126.9506 > 10.0.10.123.http: Flags [.], ack 2897, win 137, options [nop,nop,TS val 17409478 ecr 18227936], length 0
21:00:41.758489 IP 10.0.10.123.http > 10.0.10.126.9506: Flags [P.], seq 2897:4800, ack 1244, win 125, options [nop,nop,TS val 18227936 ecr 17409473], length 1903
21:00:41.758496 IP 10.0.10.126.9506 > 10.0.10.123.http: Flags [.], ack 4800, win 152, options [nop,nop,TS val 17409478 ecr 18227936], length 0
21:00:41.758499 IP 10.0.10.123.http > 10.0.10.126.9506: Flags [F.], seq 4800, ack 1244, win 125, options [nop,nop,TS val 18227936 ecr 17409473], length 0
21:00:41.758591 IP 10.0.10.126.9506 > 10.0.10.123.http: Flags [R.], seq 1244, ack 4801, win 152, options [nop,nop,TS val 17409478 ecr 18227936], length 0

答案1

我猜你需要调整和fastcgi_buffers/或fastcgi_buffer_size和可能proxy_buffers,,,。proxy_buffer_sizeproxy_busy_buffers_sizeproxy_read_timeout

答案2

我通过设置“proxy_buffer_size 8k;”解决了我的问题

相关内容