【问题标题】:How to set up a proxy location for all paths except some with apache2? [closed]如何为所有路径设置代理位置,除了一些使用 apache2 的路径? [关闭]
【发布时间】:2012-05-07 00:08:35
【问题描述】:

我的网络服务器上运行了几个网络应用程序:

  • SVN 存储库浏览器,可通过https://beta.mydomain.tld/svn/repos 访问
  • Trac 实例,可通过https://beta.mydomain.tld/trac 访问
  • 我自己的 Java Web 应用程序,可通过 http://beta.mydomain.tld/ 访问,使用端口 8080 上的本地 Apache Tomcat 代理

请注意,前两个可通过 SSL 获得,第三个(目前)尚不可用。现在我需要通过 https 使我的网络应用程序可用,但我希望 Trac 和 SVN 浏览器仍然可以在其当前位置访问。

即我正在尝试将 apache2 配置为将所有不以 svntrac 开头的请求代理到 Tomcat。

对于现有的 SSL web 应用程序,有以下配置

    <Location /svn/repos>
        DAV svn
        SVNParentPath /home/myuser/svn
        SVNListParentPath on
        AuthType Basic
        AuthName "Subversion repository"
        AuthUserFile /home/myuser/.htpasswd
        Require valid-user
    </Location>

    <Location /trac>
        SetHandler mod_python
        PythonHandler trac.web.modpython_frontend
        PythonOption TracEnvParentDir /home/myuser/trac
        PythonOption TracUriRoot /trac
        AuthType Basic
        AuthName "Trac"
        AuthUserFile /home/myuser/.htpasswd
        Require valid-user
    </Location>

我尝试添加以下位置,但没有任何帮助...

    <Location />
        ProxyPass           http://localhost:8080
        ProxyPassReverse    http://localhost:8080/
    </Location>

有关更多信息,这里是关于 SSL 部分的完整 apache2 配置(其中没有我的任何失败试验 - 我认为这是默认的 trac 配置):

<VirtualHost *:443>
    ServerAdmin webmaster@localhost
    ServerName beta.mydomain.tld:443

    DocumentRoot /var/www/
    <Directory /var/www/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride None
            Order allow,deny
            allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
            AllowOverride None
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            Order allow,deny
            Allow from all
    </Directory>

    ErrorLog /var/log/apache2/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog /var/log/apache2/ssl_access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
            Options Indexes MultiViews FollowSymLinks
            AllowOverride None
            Order deny,allow
            Deny from all
            Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

    SSLEngine on

    SSLCertificateFile    /etc/ssl/certs/ssl.crt
    SSLCertificateKeyFile /etc/ssl/private/ssl.key

    BrowserMatch ".*MSIE.*" \
            nokeepalive ssl-unclean-shutdown \
            downgrade-1.0 force-response-1.0

    <Location /svn/repos>
        DAV svn
        SVNParentPath /home/myuser/svn
        SVNListParentPath on
        AuthType Basic
        AuthName "Subversion repository"
        AuthUserFile /home/myuser/.htpasswd
        Require valid-user
    </Location>

    <Location /trac>
        SetHandler mod_python
        PythonHandler trac.web.modpython_frontend
        PythonOption TracEnvParentDir /home/myuser/trac
        PythonOption TracUriRoot /trac
        AuthType Basic
        AuthName "Trac"
        AuthUserFile /home/myuser/.htpasswd
        Require valid-user
    </Location>

【问题讨论】:

    标签: apache2 virtualhost mod-proxy


    【解决方案1】:

    只需放 ProxyPass !进入这两个位置块。这将停止代理相关位置。

    【讨论】:

      【解决方案2】:

      我有同样的场景(在 Windows 上)。对于任何为此苦苦挣扎的人:

      当我将“svn 位置”部分移动到 Proxy* 指令之前 时,它才开始对我起作用。

      <VirtualHost *:443>
        ServerName www.domain.com
        DocumentRoot "C:/Apache/domain"
        ServerAdmin admin@domain.com
      
        SSLEngine On
        SSLCertificateFile "conf/ssl/domain.crt"
        SSLCertificateKeyFile "conf/ssl/domain.key"
        SSLCertificateChainFile "conf/ssl/domain.ca-bundle.crt"
      
        <Location /svn>   
          DAV svn
          SVNPath "C:/svnrepo"
          SSLRequireSSL 
          AuthName "www.domain.com"
          AuthType Basic
          AuthUserFile "conf/svn/users"
          AuthGroupFile "conf/svn/groups"
          Require valid-user
      
          # needs to come before the ProxyPass directives
          ProxyPass !
        </Location>
      
        ProxyRequests off
        ProxyPreserveHost on
      
        ProxyPass / ajp://127.0.0.1:8080/
        ProxyPassReverse / ajp://127.0.0.1:8080/    
      </VirtualHost>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2011-11-09
        • 1970-01-01
        • 2021-01-12
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-05-19
        相关资源
        最近更新 更多