Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

remove default nginx welcome page when access directly from ip address

Tags:

nginx

ubuntu

At my ubuntu server, I install nginx and setup virtual host using this article. https://www.digitalocean.com/community/articles/how-to-set-up-nginx-virtual-hosts-server-blocks-on-ubuntu-12-04-lts--3

The virtual host's domain name is like www.example.com. When I go to www.example.com, I can see my application's index page. However, when I go to the real ip address, I still see the nginx welcome page. What can I do to remove this welcome page or point to www.example.com if someone uses ip address to access my site?

I setup a A record to point ip xxx.xxx.xxx.xxx to www.example.com.

like image 851
angelokh Avatar asked Oct 07 '13 00:10

angelokh


People also ask

How do I disable nginx welcome page?

Also you could just delete the default index files in your /var/www/html folder and you would no longer get the welcome page.

Where is nginx default page stored?

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


1 Answers

I think when you first set up nginx it comes with a "default" virtual host. Did you tried removing that? Did you tried deleting the symlink? A third option would be to add a "deny all;" on the location / of the default virtual host.

I am not exactly sure if that will work and I cannot test it right now. If the above do not work, try this out: http://nginx.org/en/docs/http/request_processing.html#how_to_prevent_undefined_server_names

http://your-server-ip/ is a request with undefined server name. You should be able to block it with:

server {     listen      80;     server_name "";     return      444; } 
like image 96
ddutra Avatar answered Oct 06 '22 05:10

ddutra