【问题标题】:apache2 forward proxy to restrict specific external ips to specific client ip's?apache2转发代理将特定外部IP限制为特定客户端IP?
【发布时间】:2016-05-09 07:27:30
【问题描述】:

假设我希望以下客户端仅访问特定的互联网 来自 apache2 转发代理后面的服务器:

Client-1-IP: www.google.com
Client-2-IP: www.gmail.com
Client-3-IP: www.cnn.com
Client-4-IP: www.chess.com

这可能吗?我在 Debian 8 上运行 Apache 2.4.10。目前, 我允许特定的客户通过这个访问整个互联网 配置值,但希望能够指定特定的 客户端只能访问特定的互联网服务器:

<VirtualHost *:8080>
        ProxyRequests On
        Proxyvia On
        <Proxy "*">
                Order deny,allow
                Deny from all
                Allow from <ip-1>
                Allow from <ip-2>
                Allow from <ip-3>
        </Proxy>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

谢谢。

【问题讨论】:

    标签: proxy apache2 client forward restrict


    【解决方案1】:

    仅供参考,这已在here 以及其他线程中进行了详细说明。在我的例子中,我想配置一个 Apache 2.4 服务器来充当另一台机器上的 Maven 的转发代理,而无需访问 Internet。请注意,Apache 2.4 中的限制语法已更改,因此 Allow/Deny/Order 关键字应替换为 Require 子句,如here 所述。例如,假设我们希望代理侦听 myhost.com:7775 并仅允许访问 192.168.1.1 并仅转发到 *.maven.org 或 *.apache.org。然后我们在 vhosts 配置中需要以下内容(我想可能有一种更简单的方法来组合多个允许的远程主机):

    <VirtualHost myhost.com:7775>
        ProxyRequests On
        ProxyVia On
    
        # block all domains except our target
        <ProxyMatch ^((?!maven\.org).)*$>
            Require all denied
        </ProxyMatch> 
    
        <ProxyMatch ^((?!apache\.org).)*$>
            Require all denied
        </ProxyMatch> 
    
        # only allow our IP for a specific target
        <ProxyMatch maven\.org >
            Require ip 192.168.1.1
        </ProxyMatch>  
    
        <ProxyMatch apache\.org >
            Require ip 192.168.1.1
        </ProxyMatch>  
    
    </VirtualHost>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-09-08
      • 2013-02-27
      • 1970-01-01
      • 2021-11-11
      • 2021-08-21
      • 1970-01-01
      • 1970-01-01
      • 2019-10-12
      相关资源
      最近更新 更多