ตัวอย่าง
สร้าง Request โดยแนบ Cookie ที่มีขนาดเกิน 8 kb
$ set TOKEN (python -c "print('a' * 1024 * 9)")
$ curl --trace full.txt --cookie "TOKEN=$TOKEN" http://localhost
จะได้ 400 Bad Request เนื่องจาก Cookie มีขนาดใหญ่ เกิด 8 kb ซึ่งเป็นค่า Default ของ NGINX
<html>
<head><title>400 Request Header Or Cookie Too Large</title></head>
<body>
<center><h1>400 Bad Request</h1></center>
<center>Request Header Or Cookie Too Large</center>
<hr><center>nginx/1.19.0</center>
</body>
</html>
วิธีแก้
ให้ปรับ large_client_header_buffers
ในไฟล์ nginx.conf
โดยเพิ่มขนาด Buffers เช่น เปลี่ยนเป็น 32 kb
Restart NGINX แล้วทดสอบอีกครั้ง จะได้ Response 200 OK ดังนี้
$ set TOKEN (python -c "print('a' * 1024 * 9)")
$ curl --cookie "TOKEN=$TOKEN" http://localhost<html><body>
<h1>Hello, world!</h1>
</body></html>* Closing connection 0