Hello!
I’m experiencing a strange issue that I’m having a very hard time troubleshooting.
An API endpoint on my site is returning a Cloudflare-branded 502 Bad Gateway error when the cookie header in the request exceeds 649 characters. Other headers seem not to matter at all in this instance.
Cloudflare documentation states that this has to be an error on my origin server.
The weird thing is that this exact request works perfectly fine when using the IP and a Host header directly, circumventing Cloudflare proxying - the size of the header does not matter at all in that case.
The server is running nginx with a very simple setup. I have confirmed that this is the virtual host both Cloudflare and the direct request are reaching.
server {
listen 80;
listen [::]:80;
access_log /var/log/nginx/site.access.log;
error_log /var/log/nginx/site.error.log;
root /var/www/html;
server_name www.example.org example.org;
location / {
client_max_body_size 60M;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
proxy_read_timeout 90;
proxy_connect_timeout 90;
proxy_redirect off;
proxy_pass http://127.0.0.1:8081;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto https;
}
}
I’ve ran a tcpdump -i any
on my server while running the requests and the failing requests through Cloudflare don’t show up in the dump, while any other requests through Cloudflare, and the direct requests for testing, do. This indicates to me that the requests don’t reach my origin server at all.
Could this possibly be an issue with my CF site configuration or with Cloudflare itself?
Thanks!