【问题标题】:Web application behind reverse proxy - how do I handle SSL?反向代理后面的 Web 应用程序 - 我如何处理 SSL?
【发布时间】:2010-12-19 06:28:32
【问题描述】:

我有一个公共 Apache 服务器,它需要代理到一个内部 Apache 服务器(用于 SVN 访问)。我想要的是:

User  ---[HTTPS]--->  Web Server  ---[HTTP]--->  SVN Server

我对 SSL 处理不太熟悉,所以我想对这种方法提出一些意见。这是一个好的模型吗?我应该在任何地方都使用 SSL,等等。

我的方法在大多数情况下都有效,但在重写重定向回 HTTPS 时失败。如果用户去

    https://acme.web.mcx/svn (no trailing '/')

它们被 SVN 服务器重定向到

    http://acme.web.mcx/svn/ (almost there!) 

这是我对 Web 服务器(代理服务器)的配置:

<VirtualHost *:443>
    ServerAdmin me@admin.com
    ServerAlias *.web.mcx www.web.mcx web.mcx

    DocumentRoot /server/web/app/webroot
    ErrorLog logs/web-error_log
    CustomLog logs/web-access_log common

    RewriteEngine On

    RewriteCond %{HTTP_HOST} !^www\.web\.mcx$ [NC]
    RewriteCond %{HTTP_HOST} ^(www\.)?([^.]+)\.web\.mcx$ [NC]
    RewriteRule ^/svn(.*) http://db.mcx/svn$1 [P]
    ProxyPassReverse /svn http://db.mcx/svn
    ProxyPreserveHost on

    SSLEngine on
    SSLCertificateFile      /etc/httpd/ssl/server.crt
    SSLCertificateKeyFile   /etc/httpd/ssl/server.key
    SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown

    ProxyRequests Off
    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>
    ProxyVia On

<Location /svn/>
    <Limit OPTIONS PROPFIND GET REPORT MKACTIVITY PROPPATCH PUT CHECKOUT MKCOL MOVE COPY DELETE LOCK UNLOCK MERGE>
        Order Deny,Allow
        Allow from all
        Satisfy Any
    </Limit>
</Location>

【问题讨论】:

    标签: apache ssl proxy mod-proxy


    【解决方案1】:

    我一直在回答我自己的问题:)

    这是我的“工作直到中断”的解决方案:我将 VirtualHost 设置更改为始终将 http:// 对 /svn* 的请求重定向到 https。客户端有时会被重定向两次(如果他们不使用斜杠),但这对我来说没问题。重定向一:SVN服务器用斜杠将客户端重定向到正确的路径(虽然忘记了https),重定向二:Web服务器将客户端重定向回https。

    <VirtualHost *:80>
        ServerAdmin me@admin.com
        ServerAlias *.web.mcx www.web.mcx web.mcx
    
        DocumentRoot /server/web/app/webroot
        ErrorLog logs/web-error_log
        CustomLog logs/web-access_log common
    
        RewriteEngine On
    
        RewriteCond %{HTTP_HOST} !^www\.web\.mcx$ [NC]
        RewriteCond %{HTTP_HOST} ^(www\.)?([^.]+)\.web\.mcx$ [NC]
        RewriteCond %{REQUEST_URI} svn.*
        RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R,L]
    
        ProxyRequests Off
    </VirtualHost>
    

    【讨论】:

    • 请接受您的解决方案,除非您希望其他替代解决方案...
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-12-27
    • 2021-03-27
    • 2015-07-30
    • 2023-03-08
    • 1970-01-01
    • 1970-01-01
    • 2016-04-13
    相关资源
    最近更新 更多