Resolved — 400 Bad Request: Request Header or Cookie too Large via Nginx

I run some of my websites via Nginx HTTP servers and some of my Nginx configuration are configured for different environments.. So when I got this error message (400 Bad Request: Request Header or Cookie Too Large) while working on one of my servers, I quickly some research and resolve it.
If you find your self in similar situation, follow the steps below to get it resolved quickly.
Oh, by the way, this could also be your browser is sending a very large cookie and the server is refusing to serve the page… In addition to a browser sending large cookie, it could also be a Nginx configuration issue and adjusting Nginx’s buffer size to accommodate large cookies could help…
If you don’t want to clear your browser cookies or reset it, then follow the steps below to adjust Nginx configuration to allow large cookies…
When you see this error message it means a header or some of the headers sent to Nginx is too large and well over the configuration limit, and Nginx is rejecting it..To get it resolved, follow the steps below:
oh, just so you know, the default buffer number and size for Nginx is 4 and 8k..
If a header size is above the limit above, you’ll get that error message..
On Nginx HTTP server, open the server configuration file…
sudo nano /etc/nginx/sites-available/example.com.conf
The location of your server configuration file may differ from above… When the file opens, add this line of configuration and save…
server {
# ...
large_client_header_buffers 4 16k;
# ...
}
Save the file and exit
The Nginx states that the line is only valid in http or server contexts…. so make sure you add the configuration line the either context… After that, restart or reload Nginx server..
sudo systemctl reload nginx.service
Test again and the error should be gone…
If you’re still getting the error after restarting, bump the number to 4 and 32k… then restart Nginx server…
Another thing to look at is if you’re running a Nginx proxy with proxy_set_header config, you should simply remove that line from your proxy configuration block…
Example, remove the line below from your proxy configuration block if you have it configured, then save and restart Nginx…
proxy_set_header Host app.example.com;
These steps above should get you back to a functioning site…
If all the steps above don’t work, there may be other issues in play there… clear your browser’s cookies and maybe reset your browser by deleting all data stored in it, hopefully it should work..

Thanks,
You may also like the post below:
Why remove proxy_set_header Host? Don’t just remove stuff you don’t understand?
VERY NICE
am sorry but please stop showing that
Very good
Why it is no working