Page 1 of 1

How to block direct IP Access?

Posted: Wed Mar 02, 2016 10:14 am
by dazdylz
Hi,

If I go to my IP address, I go to my first website. I don't want this.

How can they see a 403 error message?

This is what I have tried:

Code: Select all

server {
    listen 80;
    listen 443;
    return 403;
}


in
/etc/nginx/conf.d/default.conf

and

/etc/nginx/nginx.conf

I restarted nginx multiple times but if I go to my IP address it is not showing the 403 message. What am I doing wrong?

Re: How to block direct IP Access?

Posted: Sun Mar 06, 2016 7:28 am
by kmore
Try adding server_name directive before return :

server {
listen 80;
listen 443;
server_name IP_ADDRESS;
return 403;
}