0

When I try to log out my php application, the nginx reverse proxy throws a 502 bad gateway error.

The error log shows this error:

[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 config looks like this

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 dump log

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
wizzwizz4
  • 171
  • 7
James Kirkby
  • 168
  • 2
  • 9

2 Answers2

0

My guess would be you need to adjust fastcgi_buffers and/or fastcgi_buffer_size and possibly proxy_buffers, proxy_buffer_size, proxy_busy_buffers_size, proxy_read_timeout.

alexus
  • 13,112
  • 32
  • 117
  • 174
0

I resolved my issue by setting up "proxy_buffer_size 8k;"

  • Can you expand on this and explain why you tried that fix and why it works? Is there any documentation on this fix or what this setting does that you can refer to? – Todd Wilcox Nov 22 '17 at 19:46