tomcat上jenkins的apache子域代理插入额外目录

tomcat上jenkins的apache子域代理插入额外目录,apache,tomcat,jenkins,Apache,Tomcat,Jenkins,我的服务器上有jenkins在tomcat内部运行: http://davez0r.com:8080/jenkins 我希望apache将一个子域指向此: http://ci.davez0r.com 有以下操作说明: 因此,我用我的提供者设置了子域,然后在httpd.conf中添加了一个虚拟主机: <VirtualHost *:80> ServerName ci.davez0r.com ProxyPass / http://

我的服务器上有jenkins在tomcat内部运行:

http://davez0r.com:8080/jenkins
我希望apache将一个子域指向此:

http://ci.davez0r.com
有以下操作说明:

因此,我用我的提供者设置了子域,然后在httpd.conf中添加了一个虚拟主机:

<VirtualHost *:80>
    ServerName        ci.davez0r.com
    ProxyPass         /  http://localhost:8080/jenkins
    ProxyPassReverse  /  http://localhost:8080/jenkins
    ProxyRequests     Off

    <Proxy http://localhost:8080/jenkins*>
        Order deny,allow
        Allow from all
    </Proxy>
</VirtualHost>
在这一点上,我看到了一个空白页

我不知道是谁在做重定向。是詹金斯,阿帕奇,Tomcat

版本:

  • RHEL 6.2
  • Apache 2.2.15
  • 郊狼1.1

Tomcat正在生成重定向到正确的URL

有两种选择。到目前为止,最简单的方法是在Tomcat上部署Jenkins作为根web应用程序

更棘手的选择是弄清楚重定向是如何传回的,并在httpd中添加适当的配置来更改它。要解决您可能会看到的所有问题,您可能需要一些mod_头和mod_替换的组合。

这对我很有用:

<VirtualHost *:80>
    ServerName        ci.davez0r.com
    ProxyPass         /  http://localhost:8080/jenkins/
    ProxyPassReverse  /  http://localhost:8080/jenkins/
    ProxyRequests     Off
    ProxyPreserveHost On
    <Proxy http://localhost:8080/jenkins/*>
        Order deny,allow
        Allow from all
    </Proxy>
    RewriteEngine on
    RewriteRule   ^/jenkins/(.+) http://%{HTTP_HOST}/$1
</VirtualHost>

ServerName ci.davez0r.com
ProxyPass/http://localhost:8080/jenkins/
ProxyPassReverse/http://localhost:8080/jenkins/
代理请求关闭
代理主机
命令拒绝,允许
通融
重新启动发动机
重写规则^/jenkins/(.+)http://%{http_HOST}/$1
在代理URL后添加尾部斜杠会导致无限循环。然后在ProxyPass URL之后添加尾部斜杠使其工作,但所有静态内容的URL都不正确

所以我添加了一个重写规则来删除额外的
/jenkins/
目录,谁知道为什么会出现这个目录

<VirtualHost *:80>
    ServerName        ci.davez0r.com
    ProxyPass         /  http://localhost:8080/jenkins/
    ProxyPassReverse  /  http://localhost:8080/jenkins/
    ProxyRequests     Off
    ProxyPreserveHost On
    <Proxy http://localhost:8080/jenkins/*>
        Order deny,allow
        Allow from all
    </Proxy>
    RewriteEngine on
    RewriteRule   ^/jenkins/(.+) http://%{HTTP_HOST}/$1
</VirtualHost>