Search code examples
nginx

"unexpected "}" in /etc/nginx/sites-enabled"


I am seting up nginx for my web app and this is what my configuration looks like:

server {
    listen 80;
    server_name ip_address;

    location / {
        proxy_pass         http://127.0.0.1:8060/;
        proxy_http_version 1.1;
        proxy_set_header   Upgrade $http_upgrade;
        proxy_set_header   Connection keep-alive;
        proxy_set_header   Host $host;
        proxy_cache_bypass $http_upgrade;
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header   X-Forwarded-Proto $scheme;
    }

    location /ws {
        proxy_pass         http://127.0.0.1:8060/ws;
        proxy_http_version 1.1;
        proxy_set_header   Upgrade $http_upgrade;
        proxy_set_header   Connection "upgrade";
        proxy_set_header   Host $host;
        proxy_cache_bypass $http_upgrade;
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header   X-Forwarded-Proto $scheme;
    }
}

but when I run sudo nginx -t to test the configuration i get the folowing error:

2024/07/10 15:05:48 [emerg] 67690#67690: unexpected "}" in /etc/nginx/sites-enabled/myfirstdraft:26
nginx: configuration file /etc/nginx/nginx.conf test failed

I checked over and over and the brackets seem correct. All ";" also seem to be there.

What is going on here?


Solution

  • Using a tool to display non =printable unicode chars; you'll see that your files ends in a weird char (\uFFFFC):

    You should rewrite the last 2 lines and that will fix the issue.

    a