Hi,
I need to block direct IP access on browser. Following some suggestion, I tried to add some configuration in virtual host file of our origin server, as shown below :
<VirtualHost 192.168.33.134:80>
ServerName 192.168.33.134
Redirect 403 /
ErrorDocument 403 "Direct IP access not allowed"
DocumentRoot /dev/null
UseCanonicalName Off
</VirtualHost>
<VirtualHost 192.168.33.134:443>
ServerName 192.168.33.134
Redirect 403 /
ErrorDocument 403 "Direct IP access not allowed"
DocumentRoot /dev/null
UseCanonicalName Off
</VirtualHost>
It’s worked as expected.
Unfortunately, domain access became failed with error below :
“blocking direct IP access” generally means that you should use a firewall and allowlist only Cloudflare IPs for incoming traffic.
If you only want to force people to use your hostname, you’d do that in the 000_default config file. This is important because the file needs to be the first config in alphabetic order.
Also, you can’t use the server IP, you need to use a * if you also use that for your actual website.