3

我已经在 Tomcat 6.x 下的机器上安装了 Archiva,http://dev.mycompany.com:8080/archiva并且可以访问应用程序和所有内容,但我想从 subdomain 访问它archiva.mycompany.com

我在端口上运行 Apache 2.x,80并使用虚拟主机和 mod_proxy 从其他子域路由到我在这台机器上运行的其他各种服务。

我现在想创建一个子域archiva.dev.mycompany.com并将其指向dev.mycompany.com:8080/archiva.

我不知道我需要在我的里面放什么,ProxyPassProxyPassReverse让这项工作像我想要的那样。

我尝试了以下方法,它所做的只是/archiva一遍又一遍地添加到 URL。

<VirtualHost *:80>
    ServerAdmin me@mycompany.com
    ServerName archiva.dev.mycompany.com
    ProxyPreserveHost On

    <Proxy *>
      Order allow,deny
      Allow from all
    </Proxy>
    ProxyPass / http://dev.mycompany.com:8080/archiva
    ProxyPassReverse / http://dev.mycompany.com:8080/archiva
</VirtualHost>

我收到此错误消息

HTTP Status 404 - /archivaarchiva/
type Status report
message /archivaarchiva/  
description The requested resource (/archivaarchiva/) is not available.

我再次挖掘了我在谷歌上能找到的所有东西,并尝试了以下方法:

ProxyPass / ajp://dev.mycompany.com:8080/archiva/
ProxyPassReverse / http://dev.mycompany.com:8080/archiva/

现在我刚从 Winstone Servlet 引擎得到一个 404 错误代码,我知道我快接近了。

谁能告诉我我需要什么魔法咒语才能让它按我的意愿行事?

4

2 回答 2

2

我有同样的问题。

必须做什么:

  • 重新配置档案以使档案在 / 而不是 /archiva/ 上运行

  • 在 apache2 配置中配置反向代理。

所以现在我有“http://repo.[domain]/”作为主要档案 URL,指向“http://[domain]:[port]/”

这是我当前的 Apache2 配置:

ProxyRequests Off
ProxyPreserveHost On
<VirtualHost [ip]>

        ServerName repo.[domain]
        ProxyPass / http://[ip]:8082/
        ProxyPassReverse / http://[ip]:8082/

        <Proxy *>
              Order deny,allow
              Allow from all
        </Proxy>

</VirtualHost>

关于 conf/jetty.xml 配置:

- 删除这个:

<!--
  <Call class="org.mortbay.jetty.webapp.WebAppContext" name="addWebApplications">
    <Arg><Ref id="Contexts"/></Arg>
    <Arg>./apps</Arg>
    <Arg>org/mortbay/jetty/webapp/webdefault.xml</Arg>
    <Arg><Ref id="plusConfig"/></Arg>
    <Arg type="boolean">True</Arg>
    <Arg type="boolean">False</Arg>
  </Call>
-->

+添加这个:

  <New class="org.mortbay.jetty.webapp.WebAppContext">
    <Arg><Ref id="Contexts"/></Arg>
    <Arg>./apps/archiva</Arg>
    <Arg>/</Arg>
    <Set name="configurationClasses"><Ref id="plusConfig"/></Set>
  </New>
于 2011-03-02T19:35:36.347 回答
-1

The reason you are getting:

HTTP Status 404 - /archivaarchiva/

is because you didn't end your ProxyPass last path with a / but you did ended the first path with one.

ProxyPass / http://dev.mycompany.com:8080/archiva

both ProxyPass and ProxyPassReverse should end with /

Rewrite to (taking note of the ending /):

ProxyPass / http://dev.mycompany.com:8080/archiva/

see: http:// httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypass

If the first argument ends with a trailing /, the second argument should also end with a trailing / and vice versa. Otherwise the resulting requests to the backend may miss some needed slashes and do not deliver the expected results.

于 2013-02-15T05:29:35.977 回答