nginx: [emerg] unknown directive " " in /etc/nginx/sites-enabled/example.com:3

I had the same problem which was that I copy/pasted the config code from the web and some dirty EOL(end of line) characters where there.

The editor didn't show them, but nginx treated them like a directive.

Just deleted every EOL and added again.


It sounds like you did some copy and paste work here. It's not uncommon to snag some extra characters that are invisible at the end of line (EOL). Try this:

Run your text through this tool: http://www.textfixer.com/tools/remove-line-breaks.php

then fix any breaks that may have been removed and will be affected by the comments.

This worked for me. Hope it works for you.