65

I have the following nginx config, e.g.

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

When I restart, it warn me:

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

Any idea?

4 Answers 4

147

I guess you are missing the ; at the end of the server_name directive so it interprets the allow line as part of the server name.

server {
        listen   80;
        server_name example.com;
        allow 127.0.0.0/8;
4
  • 7
    I have been here before... I was just about to upvote your answer then I realized I already did! Thanks for a second time :-) Aug 31, 2017 at 17:01
  • Thank you. I was missing the ; at the end, and it was causing 404 Not Found nginx in my browser and server name "/var/www/mysite" has suspicious symbols in /etc/nginx/sites-available/mysite.conf:8 in my /var/log/nginx/error.log.
    – Ryan
    Apr 26, 2019 at 11:34
  • Saved a life. I guess overlooked it because nginx doesn't see it as invalid syntax. Jan 18, 2021 at 12:59
  • Typo'ing in a ':' rather a ';' will warn this as well.
    – CNSKnight
    Oct 20, 2021 at 15:43
8

For me the cause of this error was having 'http://' in the server_name.

i.e. I changed this:

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

To this:

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

A simple directive consists of the name and parameters separated by spaces and ends with a semicolon (;).

In your case server_name example.com semicolon (;) is missing.

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

In my case error was in website url

server_name  http://testapp.com;

so I modified it this way

server_name  testapp.com;

and when I tried

sudo nginx -t Outputnginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful

it worked for me

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .