【问题标题】:nginx: [emerg] could not build referer_hash, you should increase referer_hash_bucket_size: 64nginx: [emerg] 无法构建referer_hash,你应该增加referer_hash_bucket_size: 64
【发布时间】:2017-09-19 08:39:57
【问题描述】:

美好的一天,

我是 php 新手,我正在尝试在我的 ubuntu-16.04 实例中运行 livehelperchat 开源代码 (https://livehelperchat.com/),我将 Nginx 作为默认服务器监听端口 80,并且正在运行 php 5.6。

/var/www/html/sites-enabled/默认

        server {
        listen 80 default_server;
        listen [::]:80 default_server ipv6only=on;

        root /var/www/html;
        index index.php index.html index.htm index.nginx-debian.html;

        server_name xxxxxxxxx;

        location / {
            try_files $uri $uri/ =404;
        }

        error_page 404 /404.html;
        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
            root /var/www/html;
        }

        location ~ \.php$ {
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass unix:/var/run/php5.6-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

            include fastcgi_params;
        }
    }

我可以通过访问我的服务器的域名或公共 IP 地址后跟 /info.php 来访问我的网络浏览器中的 php 信息页面

我的代码位于 /var/www/html/livehelperchat/ 我已将以下链接搁置在 nginx 中设置项目 https://livehelperchat.com/nginx-configuration-tips-132a.html

/var/www/html/sites-enabled/example.conf

       server {
        listen          80;
        server_name     xxxxxxxxxxxxxxxxxxxxxxxxxxx;
        root           /var/www/html/livehelperchat;
        location ~* (^(?!(?:(?!(php)).)*/(albums|bin|var|lib|cache|doc|settings|pos|modules)/).*?(index\.php|upgrade\.php)$) {
            include        /etc/nginx/livehelperchat_fastcgi_params;
            fastcgi_pass   unix:/var/run/php5.6-fpm.sock;

            fastcgi_index  index.php;
            fastcgi_param  PATH_INFO  $query_string;
           # fastcgi_param  SCRIPT_FILENAME /var/livehelperchat/$fastcgi_script_name;
             fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        }
        #Allow hotlinking to normal and thumb size images
        location ~* (normal_|thumb_|^/design|^/cache|^/var/storagetheme)(.*)\.(gif|jpe?g?|png|mp3|svg|otf|woff|eot|ttf|ogg|wav|bmp|htm|swf|css|js|swf|pdf|ico)$ {
            ## @todo: add expires headers...
            # favicon is only stored in 1 dir, the design one; But browsers ask for it in the root
            if ($http_user_agent ~* "(WebReaper|wget|SiteSucker|SuperBot|Mihov Picture Downloader|TALWinHttpClient|A1 Website Download|WebCopier|Download Ninja|Microsoft URL Control|GetRight|Arachmo|MJ12bot|Gaisbot|Anonymous|Yanga|Twiceler|psbot|Irvine|Indy Library|HTTrack)" ) {
                return 403;
            }
            if ($http_referer ~* (stockingteensex.info|cbox.ws|teensos.net|dpstream.net|tagged.com|kaskus.us|gorilladatingservice.info|taringa.net|discuss.com|craigslist.org|poringa.net)) {
                return 403;
            }
            #sendfile off;
            #aio on;
            directio 512;
            expires max;
            access_log off;
             root           /var/www/html/livehelperchat;
        }
        # Do not allow to hotlink full size images except our self and major search engines
        location ~* \.(gif|jpe?g?|png|bmp|swf|css|js|svg|otf|eot|ttf|woff|swf|mp3|ogg|wav|pdf|ico|txt)$ {
            ## @todo: add expires headers...
            valid_referers none blocked server_names ~(livehelperchat.com|google.|reddit.|bing.|yahoo.);
            if ($invalid_referer) {
                return 403;
            }
            if ($http_user_agent ~* "(WebReaper|wget|SiteSucker|SuperBot|Mihov Picture Downloader|TALWinHttpClient|A1 Website Download|WebCopier|Download Ninja|Microsoft URL Control|GetRight|Arachmo|MJ12bot|Gaisbot|Anonymous|Yanga|Twiceler|psbot|Irvine|Indy Library|HTTrack)" ) {
                return 403;
            }
            if ($http_referer ~* (stockingteensex.info|cbox.ws|teensos.net|dpstream.net|tagged.com|kaskus.us|gorilladatingservice.info|taringa.net|discuss.com|craigslist.org|poringa.net)) {
                return 403;
            }
            #sendfile off;
            #aio on;
            directio 512;
            expires max;
             root           /var/www/html/livehelperchat;
        }
        location / {
            rewrite "^(.*)$" "/index.php?$1" last;
        }
    }

现在我在执行 nginx -t

时遇到错误
nginx: [emerg] could not build referer_hash, you should increase referer_hash_bucket_size: 64
nginx: configuration file /etc/nginx/nginx.conf test failed

服务 nginx 重启

nginx.service 的作业失败,因为控制进程以错误代码退出。详见“systemctl status nginx.service”和“journalctl -xe”。

systemctl status nginx.service

        nginx.service - A high performance web server and a reverse proxy server
           Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
           Active: failed (Result: exit-code) since Sat 2017-04-22 10:15:40 UTC; 1min 14s ago
          Process: 24237 ExecStop=/bin/sleep 1 (code=exited, status=0/SUCCESS)
          Process: 24232 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry TERM/5 --pidfile /run/nginx.pid (code=exited, status=0/SUCCES
          Process: 24111 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
          Process: 31591 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)
         Main PID: 24134 (code=exited, status=0/SUCCESS)

        Apr 22 10:15:40 ip-172-31-28-209 systemd[1]: Starting A high performance web server and a reverse proxy server...
        Apr 22 10:15:40 ip-172-31-28-209 nginx[31591]: nginx: [emerg] could not build referer_hash, you should increase referer_hash_bucket_si
        Apr 22 10:15:40 ip-172-31-28-209 nginx[31591]: nginx: configuration file /etc/nginx/nginx.conf test failed
        Apr 22 10:15:40 ip-172-31-28-209 systemd[1]: nginx.service: Control process exited, code=exited status=1
        Apr 22 10:15:40 ip-172-31-28-209 systemd[1]: Failed to start A high performance web server and a reverse proxy server.
        Apr 22 10:15:40 ip-172-31-28-209 systemd[1]: nginx.service: Unit entered failed state.
        Apr 22 10:15:40 ip-172-31-28-209 systemd[1]: nginx.service: Failed with result 'exit-code'.

我们非常感谢任何帮助。提前致谢

【问题讨论】:

  • 您是否添加了referer_hash_bucket_size?例如,location/server 块中的referer_hash_bucket_size 128;,其中指定了valid_referers
  • @Deadooshka,感谢您的快速回复。我对Linux很陌生,所以请告诉我可以将referer_hash_bucket_size更改为128的目录路径
  • 这是关于 Nginx 配置的。正如我在日志中看到的,路径是/etc/nginx/nginx.conf
  • @Deadooshka,谢谢您的宝贵时间。我已尝试添加referer_hash_bucket_size 128;在 nginx.conf 文件中,我得到了以下错误: nginx: [emerg] "referer_hash_bucket_size" 指令在 /etc/nginx/nginx.conf:24 中是不允许的 nginx: 配置文件 /etc/nginx/nginx.conf 测试失败

标签: php nginx ubuntu-16.04


【解决方案1】:

一定是 Plesk 的一个错误,正如支持人员告诉我的那样,无法再更改这些值。

我需要重新安装服务器。

【讨论】:

  • 您想重新安装完整的服务器,因为您的软件包有问题?嗯......好吧......这取决于你。如果服务器管理员无法调查和解决问题,他/她通常会重新安装依赖的软件包。 ;-) 除此之外,请考虑调查一下,如果您的 nginx - 版本已使用“ngx_http_referer_module”编译,然后再尝试添加“referer_hash_bucket_size 128;” (或类似于此可能设置的内容)。使用命令:“nginx -V”
猜你喜欢
  • 2012-12-03
  • 2023-02-10
  • 1970-01-01
  • 1970-01-01
  • 2015-02-01
  • 1970-01-01
  • 2020-04-27
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多