I’m trying just to allow access to a web server from the localhost only. This is a fresh CentOS 7 installation with apache 2.4.6.
I created a basic web:
[root@server2 ~]# cat /var/www/html/secret/index.html
my password
[root@server2 ~]#
Then, the virtualhost and directory as official documentation for apache 2.4+ (192.168.1.10 it’s the server IP and I have 192.168.1.10 serverX.example.com
in the /etc/hosts
):
[root@server2 ~]# cat /etc/httpd/conf.d/varios.conf
<VirtualHost *:80>
DocumentRoot /var/www/html/secret
ServerName serverX.example.com
</VirtualHost>
<Directory "/var/www/html/secret">
AllowOverride None
Options None
Require ip 127.0.0.1 192.168.1.10
</Directory>
[root@server2 ~]#
Everything should work, but:
[root@server2 ~]# curl serverX.example.com/secret
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
<p>You don't have permission to access /secret
on this server.</p>
</body></html>
[root@server2 ~]#
Any idea?
2
Answers
It was necesary to add one
/
at the end:With firefox works fine, but with curl or elinks, no.
Best regards.
To make the virtual host accessible to localhost only, you can bind it to the ip address 127.0.0.1.
In
/etc/hosts
you can use127.0.0.1 serverX.example.com
instead.