Apache虚拟主机代理通过两个端口以供内部(在本地网络内)和外部使用

时间:2019-02-22 10:20:11

标签: apache virtualhost proxypass

该站点有两个URL。外部为https://example.com:543 内部是https://example.com。 端口543上的外部请求在内部路由到端口443,因此正在使用端口443上具有多个ProxyPass条目的单个虚拟主机。 问题是在任何给定时间,通过禁用VirtualHost文件中的ProxyPass条目之一,仅https://example.com:543https://example.com中的一个起作用。既可以共存又可以工作吗?

#  ProxyPass             / balancer://lbyourorganization/http://localhost/VirtualHostBase/https/example.com:443/ams/VirtualHostRoot/
#  ProxyPassReverse      / balancer://lbyourorganization/http://localhost/VirtualHostBase/https/example.com:443/ams/VirtualHostRoot/

 ProxyPass             / balancer://lbyourorganization/http://localhost/VirtualHostBase/https/example.com:543/ams/VirtualHostRoot/
 ProxyPassReverse      / balancer://lbyourorganization/http://localhost/VirtualHostBase/https/example.com:543/ams/VirtualHostRoot/

下面是完整的虚拟主机配置

<VirtualHost *:443>
    ServerName example.com
    ErrorLog /var/log/apache2/ssl_error.log
    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    TransferLog /var/log/apache2/ssl_access_log
    LogLevel warn
    SSLEngine on
    SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP
    SSLCertificateChainFile /etc/apache2/ssl/example_com.ca-bundle
    <Files ~ "\.(cgi|shtml|phtml|php3?)$">
    SSLOptions +StdEnvVars
    </Files>
    SetEnvIf User-Agent ".*MSIE.*"          nokeepalive ssl-unclean-shutdown          downgrade-1.0 force-response-1.0
    CustomLog /var/log/apache2/ssl_request_log           "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

    # Balance load between 4 ZEO front-ends
    <Proxy balancer://lbyourorganization>
    BalancerMember http://127.0.0.1:8081/
    BalancerMember http://127.0.0.1:8082/
    BalancerMember http://127.0.0.1:8091/
    BalancerMember http://127.0.0.1:8092/


    # Use Pending Request Counting Algorithm (s. http://httpd.apache.org/docs/current/mod/mod_lbmethod_bybusyness.html).
    # This will reduce latencies that occur as a result of long running requests temporarily blocking a ZEO client.
    # You will need to install the separate mod_lbmethod_bybusyness module in Apache 2.4.
    ProxySet lbmethod=bybusyness
    </Proxy>


    ProxyPass /balancer-manager !
    #  ProxyPass             / balancer://lbyourorganization/http://localhost/VirtualHostBase/https/example.com:443/ams/VirtualHostRoot/
    #  ProxyPassReverse      / balancer://lbyourorganization/http://localhost/VirtualHostBase/https/example.com:443/ams/VirtualHostRoot/

    ProxyPass             / balancer://lbyourorganization/http://localhost/VirtualHostBase/https/example.com:543/ams/VirtualHostRoot/
    ProxyPassReverse      / balancer://lbyourorganization/http://localhost/VirtualHostBase/https/example.com:543/ams/VirtualHostRoot/        
</VirtualHost>

1 个答案:

答案 0 :(得分:0)

最简单的解决方案是更改路由器配置,以将外部流量指向与内部流量不同的端口(内部称为543),然后在Apache Httpd中使用两个<VirtualHost>配置,其中两个{ {1}}设置。