Nginx Proxying Long URL Addresses

Published on Author gryzli

If you are using Nginx as reverse proxy, you may encounter some of the following behaviors

Receiving Empty Lines In Nginx Log

192.168.1.1 - - [09/May/2019:10:26:58 +0300] "-" 000 0 "-" "-" "-"
192.168.1.1 - - [09/May/2019:10:09:55 +0300] "-" 000 0 "-" "-" "-"

Receiving 499 Status Code While Proxying

I was observing such behavior when trying to access some very long URL/URI’s through nginx proxying.

The bad thing is that Nginx doesn’t log anything usefull, that could be of help for locating the problem.

Most of the times with long url’s, the problem is inside your buffer configuration settings.

Here is how to get rid of these messages and fix the problem.

Proxying Long URL Addresses Over HTTP

For http only connections, you should add the following directives to your http {} or server{} config sections:

large_client_header_buffers 4 128k;

If your addresses are bigger than 128K, you should modify it accordingly.

 

Proxying Long URL Addresses Over HTTPS (HTTP2)

If you are using HTTPS with HTTP2 module, there are some additional settings you need to add:

large_client_header_buffers 4 128k;

http2_max_header_size 128k; 
http2_max_field_size  128k; 

Again the directives should be modified based on the sizes you are working with, but most of the times 128k would be sufficient.

 

Some More Resources

Configuring Nginx As Caching Reverse Proxy

Nginx 99: Cannot assign requested address to upstream

Nginx Caching Based On Page Size