httpd-xampp.conf:如何允许除本地主机外的外部IP访问?

32

在其他问题中,我没有找到适合我的正确答案。 这就是 httpd-xampp.conf 的原始外观:

#
# New XAMPP security concept
#
<LocationMatch "^/(?i:(?:xampp|security|licenses|phpmyadmin|webalizer|server-status|server-info))">
        Require local
    ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
</LocationMatch>

如果我想要在Require local之外添加另一个IP地址,我该怎么办?

例如,在Require local下面,我尝试了以下操作:

allow from xxx.xxx.xxx.xx

也就是说:

#
# New XAMPP security concept
#
<LocationMatch "^/(?i:(?:xampp|security|licenses|phpmyadmin|webalizer|server-status|server-info))">
        Require local
        allow from xxx.xxx.xxx.xx
    ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
</LocationMatch>

但它仍然阻止访问该外部IP。

我该怎么办?我如何添加更多允许访问的IP地址?

我正在Windows环境下使用XAMPP 5.6.3。

11个回答

33

allow from allRequire local 不能同时使用。可以尝试使用 Require ip xxx.xxx.xxx.xx 来替代。

例如:

# New XAMPP security concept
#
<LocationMatch "^/(?i:(?:xampp|security|licenses|phpmyadmin|webalizer|server-status|server-info))">
    Require local
    Require ip 10.0.0.1
    ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
</LocationMatch>

3
你好!我已经在Windows Server 2012上安装了xampp。我有一个公共IP,并输入了"Require ip my-ip",但仍然无法通过IP访问本地主机。谢谢。 - Lal

16

我尝试过这个方法,确实有效。但是需要注意的是,这意味着您局域网中的任何人都可以访问它。Deepak Naik 的回答更加安全。

#
# New XAMPP security concept
#
<LocationMatch "^/(?i:(?:xampp|security|licenses|phpmyadmin|webalizer|server-status|server-info))">
    # Require local
    Require all granted
ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
</LocationMatch>

8
<Directory "C:/xampp/">
    AllowOverride AuthConfig Limit
    Order allow,deny
    Allow from all
    Require all granted
</Directory>

这是我在 \xampp\apache\conf\extra\httpd-xampp.conf 文件的结尾添加的内容。


4
将以下代码添加到文件 d:\xampp\apache\conf\extra\httpd-xampp.conf 中:
<IfModule alias_module>
...
    Alias / "d:/xampp/my/folder/"
    <Directory "d:/xampp/my/folder">
        AllowOverride AuthConfig Limit
        Order allow,deny
        Allow from all
        Require all granted
    </Directory>

上述配置可以从http://127.0.0.1/访问。
注意:有人建议将Require local替换为Require all granted,但对我没有作用。
<LocationMatch "^/(?i:(?:xampp|security|licenses|phpmyadmin|webalizer|server-status|server-info))">
    # Require local
    Require all granted
    ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
</LocationMatch>

2
For Ubuntu xampp,
Go to /opt/lampp/etc/extra/
and open httpd-xampp.conf file and add below lines to get remote access,
    Order allow,deny
    Require all granted
    Allow from all

in /opt/lampp/phpmyadmin section.

使用以下命令重新启动lampp,/opt/lampp/lampp restart


0
<LocationMatch "^/(?i:(?:xampp|licenses|phpmyadmin|webalizer|server-status|server-info))">
Order deny,allow
Deny from all
Allow from all
Allow from ::1 127.0.0.0/8 
ErrorDocument 403 /error/HTTP_XAMPP_FORBIDDEN.html.var

将内容添加到 txt 文件 > httpd-xampp.conf


0

如果您想从您的计算机或手机的特定IP获得访问权限

<Directory "c:/webserver/www/">
# onlineoffline 标签-不要删除
Options Indexes FollowSymLinks
Order Deny,Allow
Allow from 127.0.0.1
Allow from ::1
Allow from localhost
Require local
Require ip 192.168.5.6
</Directory>

它100%有效!!!

 


-1
<Directory "E:/xampp/phpMyAdmin/">
AllowOverride AuthConfig Limit
Order allow,deny
Allow from all
Require all granted


-1

allow from all 与 Require local 不能同时使用。请尝试使用 Require ip xxx.xxx.xxx.xx。

例如:

# New XAMPP security concept
#
<LocationMatch "^/(?i:(?:xampp|security|licenses|phpmyadmin|webalizer|server-status|server-info))">
    Require local
    Require ip 10.0.0.1
    ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
</LocationMatch>

-1
在Windows系统中,你只需要前往Windows搜索栏找到“允许应用程序通过Windows防火墙”选项。然后点击“允许另一个应用程序”按钮,选择Apache并标记为公共和私有。按下Windows键+R打开cmd窗口,输入ipconfig命令以查找你的IP地址。在浏览器中输入你的IP地址http://172.16..x,你将会看到xampp启动页面。如果你想要访问本地网站,只需在IP地址前面加上 / ,例如http://192.168.1.x/yoursite。现在你可以在私有网络中的其他计算机上访问你的网站了。
希望这能解决你的问题。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接