如何解决nginx:[警告]无法建立最佳的proxy_headers_hash错误
时间:2020-02-23 14:39:02 来源:igfitidea点击:
nginx: [warn] could not build optimal proxy_headers_hash error 错误
如果我们拥有一个代理多个站点的Nginx代理服务器,我们可以以一种方式遇到这种错误。
“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“
为了解决错误,我们必须编辑为代理站点提供服务的文件。
我的位于/etc/nginx/sites.d/目录中。
在每个文件中,编辑"位置"部分,如下所示:
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; }
完成编辑小部分后,通过运行nginx -t命令检查nginx配置。
sudo nginx -t
你应该得到:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful