We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

Learn how to – How to solve nginx: [warn] could not build optimal proxy_headers_hash error

Learn how to – How to solve nginx: [warn] could not build optimal proxy_headers_hash error.

Introduction

How can I solve “nginx: [warn] could not build optimal proxy_headers_hash, you should increase either proxy_headers_hash_max_size: 512 or proxy_headers_hash_bucket_size: 64; ignoring proxy_headers_hash_bucket_size error“. In case you have an Nginx proxy server that proxies several sites, you may experience the error shown above in one way or the other.

In order to solve the error, you will have to edit the files that serve the proxied sites. Mine were located in /etc/nginx/sites.d/ directory.

On each of those files, edit your “location” part as shown below:

location ~ /.git {
          deny all;
     }
     proxy_redirect   off; proxy_set_header Host $host; 
     proxy_set_header X-Real-IP $remote_addr; 
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
     proxy_set_header X-Forwarded-Proto $scheme;
 ###### Set as shown below. You can use other values for the numbers as you wish
     proxy_headers_hash_max_size 512;
     proxy_headers_hash_bucket_size 128; 

     proxy_redirect   off; 
     proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; 
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
     proxy_set_header X-Forwarded-Proto $scheme;
 }

After you are done editing the small part, check your Nginx configuration by running the nginx -t command.

sudo nginx -t 

You should get:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Thank you for reading through and we hope it helped you out. Cheers

Install Varnish Cache 6 for Apache/Nginx on CentOS 7

How to hide X-Powered-By / X-CF-Powered-By PHP headers in Nginx

How To Enable GZIP & Brotli Compression for Nginx on Linux

Resolve “413 Request Entity Too Large Error” on Nginx / Apache

Cart

Your Cart is Empty

Back To Shop