Nginx: resolve error: could not build optimal proxy_headers_hash

In this article, I will explain how to fix the could not build optimal proxy_headers_hash error on Nginx when doing a configuration test with nginx -t.

This warning is displayed when publishing several dozen virtualhosts on Nginx in reverse proxy.

To solve this problem, you need to increase the value of the following parameters:

Open file /etc/nginx/nginx.conf :

sudo nano /etc/nginx/nginx.conf

In the block http { ... } add or modify the values ​​of the parameters below:

proxy_headers_hash_max_size 1024;
proxy_headers_hash_bucket_size 128;

Save changes.

Test the configuration again with the command sudo nginx -t, the warning message should no longer be present.

Reload the configuration to take into account:

sudo systemctl reload nginx



Leave a Comment