【问题标题】:How to configure Apache reverse proxy domain url to specific url on localhost如何将 Apache 反向代理域 url 配置为 localhost 上的特定 url
【发布时间】:2019-01-18 16:05:34
【问题描述】:

我遇到了配置 apache 反向代理服务器的问题。 我想使用 url eq.:https://software.testsite.net 并且我的反向代理应该使用 http://localhost:82/customapp 配置。

当前当我导航到https://www.testsite.net 时出现的问题被http://localhost:82/customapp 替换。

我该如何配置呢? 我的配置:

<VirtualHost *:443>
    SSLEngine on
    ServerName software.testsite.net
    SSLProxyEngine On

    SSLCertificateFile "${SRVROOT}/certs/testsite.crt"
    SSLCertificateKeyFile "${SRVROOT}/certs/testsite.key"
    SSLCertificateChainFile "${SRVROOT}/certs/testsite.ca-bundle"

    RequestHeader edit Destination ^https http early

    <Location />
        RedirectMatch ^/$ https://localhost:82/customapp
        ProxyPass http://localhost:82/customapp
        ProxyPassReverse http://localhost:82/customapp
    </Location>
</virtualhost>

<VirtualHost *:80>
    ProxyPreserveHost On
    ProxyVia on
    RewriteEngine on
    ProxyRequests     Off
    SSLProxyEngine On
    SSLCertificateFile "${SRVROOT}/certs/testsite.crt"
    SSLCertificateKeyFile "${SRVROOT}/certs/testsite.key"
    SSLCertificateChainFile "${SRVROOT}/certs/testsite.ca-bundle"

    # used for enforcing http to https
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{SERVER_NAME}$1 [R,L]

    ServerName software.testsite.net
    <Location />
        ProxyPass http://localhost:82/customapp
        ProxyPassReverse http://localhost:82/customapp
    </Location>

</VirtualHost>

【问题讨论】:

    标签: windows apache reverse-proxy http-proxy


    【解决方案1】:

    我终于让它工作了。不知道这是否是它应该做的方式。

    <VirtualHost *:80>
        ServerName software.testsite.net
    
        DocumentRoot "${SRVROOT}/htdocs/software"
        DirectoryIndex index.html
    
        ProxyPreserveHost On
        ProxyVia on
        RewriteEngine on
        ProxyRequests     Off
    
        # used for enforcing http to https
        RewriteEngine On
        RewriteCond %{HTTPS} off
        RewriteRule (.*) https://%{SERVER_NAME}$1 [R,L]
    
        SSLProxyEngine On
        SSLCertificateFile "${SRVROOT}/certs/testsite.crt"
        SSLCertificateKeyFile "${SRVROOT}/certs/testsite.key"
        SSLCertificateChainFile "${SRVROOT}/certs/testsite.ca-bundle"
    
        <Location /customapp>
            ProxyPass http://localhost:82/customapp
            ProxyPassReverse http://localhost:82/customapp
        </Location>
    </VirtualHost>
    
    <VirtualHost *:443>
        ServerName software.testsite.net
    
        DocumentRoot "${SRVROOT}/htdocs/software"
        DirectoryIndex index.html
    
        RequestHeader edit Destination ^https http early
        SSLEngine on
        SSLProxyEngine On
        SSLCertificateFile "${SRVROOT}/certs/testsite.crt"
        SSLCertificateKeyFile "${SRVROOT}/certs/testsite.key"
        SSLCertificateChainFile "${SRVROOT}/certs/testsite.ca-bundle"
    
        <Location /customapp>
            RedirectMatch ^/$ https://localhost:82/customapp
            ProxyPass http://localhost:82/customapp
            ProxyPassReverse http://localhost:82/customapp
        </Location>
    </virtualhost>
    
    <!DOCTYPE html>
    <html>
       <head>
          <title>HTML Meta Tag</title>
          <meta http-equiv = "refresh" content = "1; url =http://software.testsite.net/customapp"/>
       </head>
       <body>
          <p>Redirecting...</p>
       </body>
    </html>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-02-14
      • 2021-01-16
      • 2020-10-01
      • 1970-01-01
      • 2015-07-31
      • 2020-01-07
      • 2011-07-13
      相关资源
      最近更新 更多