4

My nginx server (from docker image: nginx:stable-alpine) won't start. When I check the logs I see this error:

[emerg] 1#1: unknown directive "server_name:" in /etc/nginx/conf.d/default.conf:4

Here is my config file:

server { listen 80; index index.php index.html; server_name: localhost; error_log /var/log/nginx/error.log; access_log /var/log/nginx/access.log; root /var/www/html/public; location / { try_files $uri $uri/ /index.php?$query_string; } location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass php:9000; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; } } 

I tried searching fot his error and read something about it supposed to be in an http block so when I tried adding

http { 

at the begining and

} 

at the end I get a different error

[emerg] 1#1: "http" directive is not allowed here in /etc/nginx/conf.d/default.conf:1

So I'm not sure what else to try.

1
  • You have a spurious : after server_name. See this document. Commented Jun 6, 2020 at 7:54

1 Answer 1

8

There is no server_name: in NGINX, indeed.

There is server_name. You should not include colon :, then it will work.

You must log in to answer this question.