【问题标题】:Allow internet users to access privately hosted website pages允许互联网用户访问私人托管的网站页面
【发布时间】:2017-08-31 17:17:27
【问题描述】:

我有一个企业专用网络 (VPN),并且在一个虚拟机上托管了一个网站,该网站只能在内部访问。例如https://internal.com/welcome.html

现在,我想允许从外部访问网站的几个页面,但使用它们自己的 url。

例如他们将打开http://theirdoamin.com/welcome.html,它将被重定向到我的专用网络,并且在内部它将被映射/代理到https://internal.com/welcome.html

这种方式外面永远不会知道实际的网址(即https://internal.com/welcome.html

我的问题是,我们能否使用位于我的托管虚拟机前面的 Apache 反向代理服务器来实现这一点?

第二个问题,我也可以限制只访问welcome.html页面而不访问其他页面吗?

我的同事已经使用 Apache Nifi 实现了,但我仍然相信使用 Apache 反向代理设置可以很简单地完成。

请指教。

谢谢

【问题讨论】:

    标签: apache networking virtualhost reverse-proxy vpn


    【解决方案1】:

    1) 是的,Apache 反向代理能够做到这一点。 2) 您可以根据需要限制访问。

    1) 我设置了两个vhosts(用于examples),一个使用原始名称,一个使用VPN 可访问名称。

    Listen 80
    
    #If you are running a Apache 2.2 you'll need the following line, for 2.4 you won't
    NameVirtualHost *:80
    
    <VirtualHost *:80>
        DocumentRoot "srv/www/example1"
        ServerName internal.com
    
        <Directory "/srv/www/example1">
            Require all granted
        </Directory>
    
        # Other directives here, if needed
    </VirtualHost>
    
    <VirtualHost *:80>
        ServerName external.com
    
        ProxyPreserveHost On
        RewriteEngine On
        RewriteRule ^ https://internal.com/welcome.html [P]
        ProxyPassReverse / https://internal.com/
    </VirtualHost>
    

    您需要 RewriteRule 来定位特定文件而不是整个域。否则一个简单的ProxyPass 就足够了。

    这需要激活模块 mod_rewritemod_proxymod_proxy_http

    2) 由 RewriteRule 完成。它只允许访问特定的目标文件 (welcome.html)。

    【讨论】:

    • 感谢您提供详细解释和示例的回复。我将尝试实施并希望它应该完成。
    猜你喜欢
    • 2011-06-11
    • 1970-01-01
    • 2021-08-28
    • 2019-12-01
    • 1970-01-01
    • 2014-08-11
    • 2015-07-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多