Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nginx only shows welcome page

Tags:

nginx

I'm trying to set up a simple virtual host, serving only static files. Trouble is, directing the browser to (in this case) jorum.dev displays the default nginx welcome page, as opposed to jorum.dev/index.html.

Nginx was installed using Homebrew on Mac OS X Mountain Lion.

hosts

127.0.0.1       jorum.dev 

jorum.dev

server {     listen          80;     server_name     jorum.dev;      location / {         root        ~/Sites/jorum;         index       index.html index.htm;     } } 

nginx.conf

worker_processes  1;  events {     worker_connections  1024; }  http {     include       mime.types;     default_type  application/octet-stream;      sendfile        on;      gzip            on;     gzip_disable    "msie6";     gzip_min_length 1100;     gzip_vary       on;     gzip_proxied    any;     gzip_buffers    16 8k;     gzip_types      text/plain text/css application/json application/x-javascript text/xml application/xml application/rss+xml text/javascript image/svg+xml application/x-font-ttf font/opentype application/vnd.ms-fontobject;      server_tokens off;      client_max_body_size    4096k;     client_header_timeout   10;     client_body_timeout     10;     keepalive_timeout       10 10;     send_timeout            10;      server {         listen       80;         server_name  localhost;          location / {             root   html;             index  index.html index.htm;         }          #error_page  404              /404.html;          # redirect server error pages to the static page /50x.html         #         error_page   500 502 503 504  /50x.html;         location = /50x.html {             root   html;         }     } } 
like image 758
jdlm Avatar asked Jan 22 '13 14:01

jdlm


People also ask

Why am I seeing welcome to nginx?

A web page saying “Welcome to nginx!” is just a diagnostics response that can be produced by any of the websites out there, running nginx web server. Currently, nginx is the 2nd most popular open source web server in the world, it's being used by over 126,000,000 (or 14% of the Internet) websites.

How do I remove nginx welcome page?

If you removed default under /etc/nginx/sites-available and restarted nginx and the welcome page is still showing, then see if there is a default. conf under /etc/nginx/conf. d and delete it and then restart nginx.

How do I get the default page in nginx?

Looking at default configuration file in /etc/nginx/sites-available/default showed the path to be the same as the --prefix path. But the configuration file located at /etc/nginx/conf. d/default. conf listed the root as /usr/share/nginx/html.

Where is the default nginx index html?

By default Nginx Web server default location is at /usr/share/nginx/html which is located on the default file system of the Linux.


2 Answers

the debian/ubuntu nginx package comes with a default sites-available that takes over the default host dispatch. Simply remove the default link and it should load your site instead.


another gotcha, the debian/ubuntu nginx package also comes with a default index value for the default server in the default site that reads:
index index.html index.htm index.nginx-debian.html; 

I've had the file index.nginx-debian.html show up in my www root directory, which took precedence over the cgi locations.


nginx has a verbose test mode that can be used to dump the entire configuration as parsed by nginx, which you can sanity check against your expectations.

nginx -T 
like image 78
ThorSummoner Avatar answered Sep 18 '22 04:09

ThorSummoner


Missing includes in nginx.conf

include /usr/local/etc/nginx/sites-enabled/*; 

http://wiki.nginx.org/CoreModule#include

like image 21
freestyler Avatar answered Sep 22 '22 04:09

freestyler