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
Romain Drouche

Romain Drouche

Architecte Système | MCSE: Core Infrastructure

Expert en infrastructures IT avec plus de 15 ans d'expérience sur le terrain. Actuellement Chef de projet Systèmes et Réseaux et Référent SSI (Sécurité des Systèmes d'Information), je mets mon expertise au service de la fiabilité et de la sécurité des environnements technologiques.

GHinM▶