nginx: [emerg] unexpected end of file, expecting “;” or “}” in filename:linenumber

I created a new vhost for a domain to serve static files. Here’s the config…

 

server {
    server_name static.example.com;

    root "/path/to/static.example.com/public;

    index index.html;

    access_log /var/log/nginx/static.example.com-access.log;
    error_log /var/log/nginx/static.example.com-error.log;

    location / {
        try_files $uri $uri/ /index.html;
    }
}

It can’t get simpler than this. However, when I checked the configuration with `nginx -t`, it threw the following error…

nginx: [emerg] unexpected end of file, expecting ";" or "}" in /path/to/static.example.com/public:15

It had exactly 15 lines and the error happened exactly at the end of the file. I was too confused about this. Finally, I decided to check each character of this config. Turned out that I missed the matching quote around the `root` path.

Time to stop using quotes. Nginx can work without quotes too. However, quotes are necessary, if there is a space in the path.

It is easy to catch these kind of errors, if we turned on the syntax highlighting in my editor. While I did turn it on, the configuration was located in a specific path that the editor failed to apply the syntax highlighting on this particular file. Time to fine-tune it!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s