Need help configuring nginx

Hi Guys ,

Currently users can view my files using both server ip and my dns record .

For example if you open my server ip ( ) , It will show index page and If you open again you will get the index page . I want to block access to nginx by ip address . I mean if a user tries to access nginx by my server ip ( ) , he would get nothing . I want my nginx files to be available only with my dns ( )

How can I do so ?

Sorry for my bad English !

Cheers ,


I’m not very familiar with configuring Nginx, but when using Apache, I know that to do that, you would need to use a .htaccess file to prevent one from accessing a site using an IP address.

Either that, or change the default website to a different site. If you setup the default website as a generic site, that may also solve the problem.


Hi Eric ,

That didn’t help . Still users can see the index page both by using the site address and IP address . I want my site to be only available by its address not by the IP !

I can’t figure a way to do this .

Any help will be appreciated