kailtom
By:
kailtom

Nginx Server does not start.

January 18, 2017 691 views
Nginx Ubuntu

Good afternoon!

I created a server block (Nginx), I did the whole process! Restarted the Nginx and then not returned! The retonor is: Start: nginx [Failed].

Searching I found the error! Accidentally didn't put the semicolon in charge (/etc/nginx/sites-available/exemplo.com). To try to solve the problem I put the semicolon (;) but even then Nginx does not start! As soon as I deleted the server block that I created, however, the same does not start anymore.

Follow the error appears in the log file:

2017/01/18 13:20:59 [emerg] 19304#19304: unexpected end of file, expecting ";" or "}" in /etc/nginx/sites-enabled/1:9
2017/01/18 13:51:55 [emerg] 19406#19406: unexpected end of file, expecting ";" or "}" in /etc/nginx/sites-enabled/1:9

Can someone help me? Remember, I'm new to Nginx.

4 Answers

@kailtom

Please post the server block and I'll be more than happy to take a look at it for you. What we need to look at is everything between:

server {

and the closing

}
  • Follows the block: default
    http://pastebin.com/9NEQqhx1

    Block: 22222
    http://pastebin.com/x895uFGr

    Block: dwbox.com.br
    http://pastebin.com/mS7vQiNf

    Below is the server block that I deleted. And yet the Nginx does not start, after a few hours he appeared again, only the name came different: vplastico.com.br. save

    The code below is not the original. I made changes to see if she'd be back to normal, in case I made a copy of the Default and through this I created the vplastico.com.br again, but still no start Nginx. In relation to vplastico.com.br. save also did the same procedure.

    Block: vplastico.com.br
    http://pastebin.com/RZGqNQk6

    I thank you!

@kailtom

The issues are with this server block: http://pastebin.com/x895uFGr

The first issue I'm seeing is with this line:

# Force HTTP to HTTPS
error_page 497 =200 https://$host:22222$request_uri;

The above does not force HTTP to HTTPS, it sets an error page and enforces and internal redirect. It could very well be used to push HTTP to HTTPS, though that's not what this was actually intended for.

Ideally, you'd setup a server block that looks like this to handle HTTP (on Port 80) redirects to HTTPS (on Port 443).

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    server_name _;
    return 301 https://$host$request_uri;
}

While this isn't actually what's causing the issue, it can result in some rather odd logs appearing since the error_page definition isn't meant for handling redirects to SSL and should be used for it's actual intended usage.

The actual issue, however, is that this server block is missing the closing } at the end of the file.

Below this block:

  location ~* /vimbadmin/public/(.*) {
    root /var/www/22222/htdocs/vimbadmin/public;
    try_files $uri $uri/  /vimbadmin/public/index.php?$args;
  }

You need another closing }, so it should look like:

  location ~* /vimbadmin/public/(.*) {
    root /var/www/22222/htdocs/vimbadmin/public;
    try_files $uri $uri/  /vimbadmin/public/index.php?$args;
  }
}

Why? Without that last }, you're leaving the server { block portion open, so it's trying to find more configuration that doesn't exist. Simply add that last closing } and then run:

service nginx reload

and that should get you squared away. If, however, another issue pops up, please let me know and we'll take look at that error and see what the issue is.

  • Sorry jtittle!

    The environment of the Nano (text editor) is complicated, just forgot to copy the key. In that case the error remains (Nginx does not start).

    Searching in bing I found a few more things in this one command of Nginx which makes an analysis (errors). Running the command (nginx-t) was showing the following:

    root@mail:/# nginx -t
    nginx: [emerg] unexpected end of file, expecting ";" or "}" in /etc/nginx/sites-enabled/1:9
    nginx: configuration file /etc/nginx/nginx.conf test failed

    Follows the nginx file contents:

    http://pastebin.com/KrjBY0PK

    I thank you!

@kailtom

The best way to get around the copy and paste issues when using nano would be to login as root to the Droplet using SFTP (using root as your username, your root password, and your Droplet IP -- you'll connect on Port 22).

After you've successfully logged in, navigate to your NGINX directory and download the files and then copy and paste from your local text editor.

The reason being is because in the Pastebin you just provided, the issue is with this line:

        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA2$

As it ends with a $ instead of a ; -- and that appears to be an issue as the contents of that file was copied from your terminal instance instead of from the file locally.

So you'll need to download the main file, nginx.conf and the server blocks associated with the sites you're hosting (i.e. all configuration files starting with server {).

  • Thank you!

    Follow the link with the server blocks and nginx file via SFTP:

    https://mega.nz/#!9IcTiCYY!-BBQTQy6iubwb51F6acHIKEaETbONqGIKA9HBZ-LcLU

    • @kailtom

      Ok, with a clear view of those files, it doesn't look like there's an issue there, so the next place we need to look is at the files you're including in each of the files.

      would it be possible for you to simply GZIP the entire NGINX directory and let me take a look at all the files? I've ran EasyEngine before and normally, their configuration is spot on, but with numerous includes being present and not having access to all the files, it's hard to see exactly where the issue is.

      Providing me with the entire /etc/nginx directory will give me a look at everything.

      • Good morning!

        Thank you brother for your help! I didn't before because I was looking at the directory before you forwards. However, this analysis found a file that was generated by the EasyEngine in the directory /etc/nginx/sites-available. Have a file with the name (1). Soon joined the error generated when you run the nginx-t:

        root@mail:/etc/nginx/sites-enabled# nginx -t
        nginx: [emerg] unexpected end of file, expecting ";" or "}" in /etc/nginx/sites-enabled/1:9
        nginx: configuration file /etc/nginx/nginx.conf test failed

        This 1:9 is for the file generated by EasyEngine, just below follows the same content:

        ^[[34mUpdating EasyEngine Database^[(B^[[m
        Error: near line 1: duplicate column name: dbname
        Error: near line 1: duplicate column name: db
        user
        Error: near line 1: duplicate column name: dbpassword
        Error: near line 1: duplicate column name: db
        host
        Error: near line 1: duplicate column name: ishhvm
        Error: near line 1: duplicate column name: is
        pagespeed
        Error: near line 1: duplicate column name: php_version

        Now I have a question can I delete this file or do I have to put the; or create block policies?

@kailtom

If the file is not a valid server block and it serves no actual purpose, you should be able to delete it without any issues. If that doesn't resolve the issues you're having though, I'd need to take a closer look at the rest of your configuration as there are so many includes in the files, it's hard to see where the actual error is since NGINX is't actually giving a file (which is most likely due to the number of includes).

Have another answer? Share your knowledge.