使用 Apache 2.x 和 Tomcat 6.x 将子域映射到 Servlet 上下文
我已在 Tomcat 6.x 下的计算机上安装了 Archiva(位于 http://dev.mycompany.com:8080/archiva
),并且可以访问该应用程序和所有内容,但我想从子域访问它archiva.mycompany.com
。
我在端口 80
上运行 Apache 2.x,并使用虚拟主机和 mod_proxy 从其他子域路由到我在这台计算机上运行的其他各种服务。
我现在想要创建一个子域 archiva.dev.mycompany.com
并将其指向 dev.mycompany.com:8080/archiva
。
我不知道需要在 ProxyPass
和 ProxyPassReverse
中放入什么才能使其按我希望的方式工作。
我尝试了以下操作,它所做的只是一遍又一遍地将 /archiva
添加到 URL 中。
<VirtualHost *:80>
ServerAdmin [email protected]
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.
我再次挖掘了我在 Google 上可以找到的所有内容,并尝试了以下操作:
ProxyPass / ajp://dev.mycompany.com:8080/archiva/
ProxyPassReverse / http://dev.mycompany.com:8080/archiva/
现在我刚刚从 Winstone Servlet 引擎收到 404 错误代码,我知道我已经接近了。
谁能告诉我需要什么魔法才能让它按照我的意愿行事?
I have installed Archiva on my machine under Tomcat 6.x at http://dev.mycompany.com:8080/archiva
and can access the application and everything, but I want to access it from the subdomain archiva.mycompany.com
.
I have Apache 2.x running on port 80
and using Virtual Hosts and mod_proxy to route from other subdomains to the other various services I am running on this machine.
I now want to create a subdomain archiva.dev.mycompany.com
and point that to dev.mycompany.com:8080/archiva
.
I can't figure out what I need to put in my ProxyPass
and ProxyPassReverse
to make this work like I want it to.
I tried the following and all it does is add /archiva
to the URL over and over again.
<VirtualHost *:80>
ServerAdmin [email protected]
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>
and I get this error message
HTTP Status 404 - /archivaarchiva/
type Status report
message /archivaarchiva/
description The requested resource (/archivaarchiva/) is not available.
I went and dug through everything I could find on Google once again and tried the following:
ProxyPass / ajp://dev.mycompany.com:8080/archiva/
ProxyPassReverse / http://dev.mycompany.com:8080/archiva/
now I just get a 404 error code from the Winstone Servlet Engine, I know I am getting close.
Can anyone tell me what magic incantation I need to make this behave as I desire?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我遇到了完全相同的问题。
必须做什么:
重新配置档案以拥有档案
在 / 而不是 /archiva/ 上运行
在中配置反向代理
apache2 配置。
所以现在我有“http://repo.[domain]/”作为主档案 URL,指向“http://[domain]:[port]/”
这是我当前的 Apache2 配置:
以及关于 conf/jetty.conf 的配置。 xml 配置:
-删除此:
+添加此:
I had the exact same problem.
What has to be done :
reconfigure archiva to have archiva
running on / instead of /archiva/
configure reverse proxy in the
apache2 configuration.
So now i have "http://repo.[domain]/" for main archiva URL, pointing on "http://[domain]:[port]/"
Here's my current Apache2 configuration :
And about the conf/jetty.xml configuration :
-remove this :
+add this instead:
您收到的原因是:
HTTP Status 404 - /archivaarchiva/
是因为您没有用 / 结束 ProxyPass 最后一条路径,但确实用 / 结束了第一个路径。
ProxyPass / http://dev.mycompany.com:8080/archiva
ProxyPass 和 ProxyPassReverse 都应该结束用 /
重写为(注意结尾 /):
ProxyPass / http://dev.mycompany.com :8080/archiva/
请参阅:http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypass
如果第一个参数以尾随 / 结尾,则第二个参数也应以尾随 / ,反之亦然。否则,对后端的最终请求可能会错过一些所需的斜杠,并且不会提供预期的结果。
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.