Nginx配置上的可疑符号


41

我有以下nginx配置,例如

server {
        listen   80;
        server_name example.com
        allow 127.0.0.0/8;

重新启动时,它会警告我:

Restarting nginx: nginx: [warn] server name "127.0.0.0/8" has suspicious 
symbols in /etc/nginx/sites-enabled/xxx

任何想法?

Answers:


101

我猜您;server_name指令末尾缺少,因此它将allow行解释为服务器名称的一部分。

server {
        listen   80;
        server_name example.com;
        allow 127.0.0.0/8;

4
我以前来过这里...我正要赞成你的回答,然后我才知道我已经做到了!再次感谢您:-)
codenamejames

谢谢。我错过了;末,它是造成404 Not Found nginx在我的浏览器,并server name "/var/www/mysite" has suspicious symbols in /etc/nginx/sites-available/mysite.conf:8在我的/var/log/nginx/error.log
瑞安

3

对我来说,此错误的原因是server_name中有“ http://”。

即我改变了这个:

server {
    listen <Server name>:80;
    server_name <DNS name> http://localhost:28080;
    ...

对此:

server {
    listen <Server name>:80;
    server_name <DNS name> localhost:28080;
    ...

2

一个简单的指令由名称和参数组成,这些名称和参数之间用空格隔开,并以分号(;)结尾。

在您的情况下,缺少server_name example.com分号(;)。

server {
        listen   80;
        server_name example.com;
        allow 127.0.0.0/8;
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.