2

我有一个公共 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>

4

1 回答 1

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>
于 2010-12-19T06:45:40.100 回答