apache2 - 如何为所有路径设置代理位置,除了一些使用 apache2 的路径?

标签 apache2 virtualhost mod-proxy

关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。












想改进这个问题?将问题更新为 on-topic对于堆栈溢出。

2年前关闭。




Improve this question




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

  • 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 浏览器仍然可以在其当前位置访问。

    IE。我正在尝试将 apache2 配置为代理所有不以 svn 开头的请求或 trac到 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>
    

    最佳答案

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

    关于apache2 - 如何为所有路径设置代理位置,除了一些使用 apache2 的路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10330374/

    相关文章:

    MacOS Sierra : apachectl is using configuration from/usr/local/etc/apache2/2. 4 而不是/etc/apache2/

    Apache2 (CKAN) + TOMCAT6 + Mod 代理问题

    dynamic - 如何在nginx中设置海量动态虚拟主机?

    wordpress - 为完美的 Wordpress 环境配置 VirtualHost

    linux - 从 virtualhost proxypass 中排除别名

    tomcat - 使用 mod_proxy 将调用从 apache2 重定向到 tomcat 时出现问题

    linux - 哪个负载均衡器的性能更好 mod_jk 或 mod_proxy 或任何其他开源

    security - 将 Pem/der 证书导入 kdb 文件

    apache - 无法在 Ubuntu 20.04 上安装 Apache2

    django - 使用 django 和 apache2 设置权限的正确方法?