Nginx unexpected end of file expecting ";" or "}" in / etc / nginx / sites -enabled / default: 20 over Raspbian

I am new to nginx and raspberries.

I installed nginx using

sudo apt-get install

And everything was in order. The problem arose when I tried to restart nginx, it threw this error

Work for nginx.service failed. See "Systemctl status ngins.service" and "journaldtl -xn" for details.

After the investigation, I found that the problem is the following error:

unexpected end of file waiting for ";" or "}" in / etc / nginx / sites -enabled / default: 20

My default file is:

# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples. ## server { #listen 80; ## listen for ipv4; this line is default and implied #listen [::]:80 default_server ipv6only=on; ## listen for ipv6 listen 80; server_name $domain_name; root /var/www; index index.html index.htm; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; # Make site accessible from http://localhost/ server_name localhost; location / 

Hope you can help me :)

+8
source share
4 answers

as @Thanh Nguyen Wang already answered. location should be opened and closed in braces, and then another brace for the end of your server

 server { #listen 80; ## listen for ipv4; this line is default and implied #listen [::]:80 default_server ipv6only=on; ## listen for ipv6 listen 80; server_name $domain_name; root /var/www; index index.html index.htm; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; # Make site accessible from http://localhost/ server_name localhost; location / { } } 
+3
source

I had the same problem. It is confirmed that at the end of the newly added line inside the server block '{...}' is missing ; .

Make sure that the braces and ; everything is in place.

+4
source

Fix your nginx file as shown below:

For instance:

 http { upstream api-app { .....................; } ........................; server { location / { ...................; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; } } } 

Make sure that ; at the end of the line and { ..} correct.

+1
source

Also make sure that you do not have unexpected quotes (single or double). It took me a while to figure out when I used Docker and passed the value as an env variable, so it was mistakenly quoted.

So this will be the wrong bit:

 upstream backend { "server localhost:9000;" } 

It is right:

 upstream backend { server localhost:9000; } 
0
source

All Articles