httpd-xampp.conf:如何允许访问除localhost之外的外部IP?

时间:2015-01-15 18:20:37

标签: apache xampp httpd.conf

在其他问题上,我找不到适合我的正确答案。 这就是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。

10 个答案:

答案 0 :(得分:29)

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 :(得分:11)

我试过这个并且它有效。但要小心。这意味着LAN中的任何人都可以访问它。 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>

答案 2 :(得分:5)

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

这是我在标签

之前添加到文件\ xampp \ apache \ conf \ extra \ httpd-xampp.conf文件末尾的内容

答案 3 :(得分:1)

将以下代码添加到文件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>

答案 4 :(得分:1)

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.

使用/opt/lampp/lampp restart

重启lampp

答案 5 :(得分: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

答案 6 :(得分:-1)

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

答案 7 :(得分:-1)

在Windows中你所要做的就是转到Windows搜索通过Windows防火墙允许应用程序。单击“允许其他应用程序选择Apache”并标记公共和私有两者。通过按下Windows按钮打开cmd + r写入cmd比在cmd中写入ipconfig找出你的ip。比打开你的浏览器记下你的ip http://172.16..x,你将进入xampp启动页面。如果你想访问你的本地网站,只需将你的ip放在/面前,例如http://192.168.1.x/yousite。现在,您可以在专用网络计算机中访问您的网站。

我希望这能解决您的问题

答案 8 :(得分:-1)

所有的

allow不能与Require local一起使用。相反,请尝试要求ip xxx.xxx.xxx.xx

例如:

const loggingBunyan = new LoggingBunyan();
const logger = bunyan.createLogger({
    name: 'my-service',
    level: 'info',
    streams: [
            {stream: process.stdout},
            loggingBunyan.stream(),
        ],
});

app.get('/', (req, res) => {
  var data_block = {
    "glossary": {
        "title": "example glossary",
        "GlossDiv": {
            "title": "S",
            "GlossList": {
                "GlossEntry": {
                    "ID": "SGML",
                    "SortAs": "SGML",
                    "GlossTerm": "Standard Generalized Markup Language",
                    "Acronym": "SGML",
                    "Abbrev": "ISO 8879:1986",
                    "GlossDef": {
                        "para": "A meta-markup language, used to create markup languages such as DocBook.",
                        "GlossSeeAlso": ["GML", "XML"]
                    },
                    "GlossSee": "markup"
                }
            }
        }
    }
  }
  res.status(200).send('Hello, world!').end();
  logger.info(data_block);
});

答案 9 :(得分:-3)

打开新应用&#34; HTTPD&#34;防火墙中的(Apache服务器)

看看这个:https://www.youtube.com/watch?v=eqgUGF3NnuM

相关问题