33

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?

86

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;
  • 3
    I have been here before... I was just about to upvote your answer then I realized I already did! Thanks for a second time :-) – codenamejames Aug 31 '17 at 17:01
3

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;
    ...
2

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;

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.