我正在尝试在 apache 上托管我的项目日志的索引,以便从内部网络访问。
网站位置是 /srv/www/htdocs。我尝试将允许 IP 放在那里的 .htaccess 文件中,但没有成功。
我也尝试将其放入 httpd.conf 文件中 httpd配置文件
那也没用。我尝试只让一台计算机使用静态 IP 来访问它。Apache 2.4 在 OpenSuse 上运行
# global (server-wide) SSL configuration, that is not specific to
# any virtual host
Include /etc/apache2/ssl-global.conf
# global (server-wide) protocol configuration, that is not specific
# to any virtual host
Include /etc/apache2/protocols.conf
# forbid access to the entire filesystem by default
<Directory />
Options None
AllowOverride ALL
<IfModule !mod_access_compat.c>
Require all denied
</IfModule>
<IfModule mod_access_compat.c>
Order deny,allow
Deny from all
</IfModule>
</Directory>
<Directory "/var/www/htdocs/">
Options Indexes FollowSymLinks
AllowOverride None
REquire all denied
Require ip 192.168.30.54
</Directory>
# use .htaccess files for overriding,
AccessFileName .htaccess
# and never show them
<Files ~ "^\.ht">
<IfModule !mod_access_compat.c>
Require all denied
</IfModule>
<IfModule mod_access_compat.c>
Order allow,deny
Deny from all
</IfModule>
</Files>
v:78.0) Gecko/20100101 Firefox/78.0"
192.168.30.13 - - [26/Feb/2021:00:23:54 -0500] "GET / HTTP/1.1" 200 2257 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0"
192.168.30.13 - - [26/Feb/2021:00:23:54 -0500] "GET /favicon.ico HTTP/1.1" 404 985 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0"
192.168.30.13 - - [26/Feb/2021:00:34:13 -0500] "GET / HTTP/1.1" 304 - "-" "Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0
答案1
httpd.conf 中的正确条目应该是:
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride None
Require all denied
Require ip 192.168.0.10
</Directory>
您应该将其放在一个<Directory>
部分中。有关更多信息,您可以咨询 *moth_authz_core文档:
https://httpd.apache.org/docs/2.4/mod/mod_authz_core.html