How to block direct IP Access?
How to block direct IP Access?
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:
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?
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?
Try adding server_name directive before return :
server {
listen 80;
listen 443;
server_name IP_ADDRESS;
return 403;
}
server {
listen 80;
listen 443;
server_name IP_ADDRESS;
return 403;
}