Not able to get Nginx to show anything other than "welcome to nginx"
I am trying to set up an nginx install on a Amazon Lightsail VPS running Debian (not the Nginx Bitnami package). I'm a bit of a newbie at this. I'm totally puzzled by what is happening.
Output of ls -l /etc/nginx/sites-enabled
:
lrwxrwxrwx 1 root root 39 Jul 27 16:39 static -> /etc/nginx/sites-available/static
Contents of /etc/nginx/sites-available/static
:
server { listen 80; listen [::]:80; server_name 'DOMAIN NAME' www.'DOMAIN NAME' www1.'DOMAIN NAME' 'IP ADDRESS OF SERVER' root /var/www/static index index.html; location / { index index.html; try_files $uri $uri/ =404; } }
In the above, DOMAIN_NAME
and IP ADDRESS
are placeholders for the real text.
Output of nginx -T
shows the contents of static
displayed after the contents of /etc/nginx/nginx.conf
. There are no server-name
lines in this output except what's in static
.
/var/log/nginx/access.log
shows accesses when I enter the main domain name, but not the subdomain names. In any case, whether I enter the subdomain or just the main domain, I am shown the welcome page.
What's even more mystifying is that the welcome page seems to be at /var/www/html/index.html
. So I modified that file too as a test. But the modified version wasn't displayed either.
I'm at my wit's end. What have I done wrong?
The comment from @RichardSmith on the question pointed me to the right answer.
I'd used code from other websites to construct my server block file (/etc/nginx/sites-available/static
). But some of that code was wrong - it did not terminate every line with a ;
.
Once I added that to the file, like so:
server { listen 80; listen [::]:80; server_name 'DOMAIN NAME' www.'DOMAIN NAME' www1.'DOMAIN NAME' 'IP ADDRESS OF SERVER'; root /var/www/static; index index.html; location / { index index.html; try_files $uri $uri/ =404; } }
It worked perfectly!
NB: Wish nginx -t
would have given me a warning about this though...