配置虚拟主机 Apache
我一直在尝试配置我的apache服务器以支持虚拟主机,这些主机然后会将端口80发出的任何请求重定向到Jboss AS中托管的不同应用程序,因此例如我的配置将是这样的:
<VirtualHost *:80>
ServerName www.testdomain.com
ProxyPass / http://localhost:8080/contextPath
ProxyPassReverse / http://localhost:8080/contextPath
ProxyPreserveHost On
ProxyPassReverseCookiePath / /
</VirtualHost>
但是问题是当我尝试访问 http://www.testdomain.com 时,URL 被有效重定向到本地主机: 8080 然而,我得到了重复的上下文路径。 IE:http://www.testdomain.com/contextPath/contextPath。
任何想法为什么会发生这种情况。多谢。
I have been trying to configure my apache server to support virtual hosts, these hosts, would then redirect any request made at port 80 to different applications hosted in a Jboss AS, so for example my configuration would be like this:
<VirtualHost *:80>
ServerName www.testdomain.com
ProxyPass / http://localhost:8080/contextPath
ProxyPassReverse / http://localhost:8080/contextPath
ProxyPreserveHost On
ProxyPassReverseCookiePath / /
</VirtualHost>
However the problem is that when I'm trying to access http://www.testdomain.com, the url gets redirected effectively to localhost:8080, however, I got a duplicated context path. I.E: http://www.testdomain.com/contextPath/contextPath.
Any ideas why is this happening. Thanks a lot.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我遇到了同样的问题,通过在网址中添加正斜杠解决了这个问题。
这为我解决了!
单个虚拟主机文件的完整示例。我有几个,每个域和子域一个。
I had the same issue and this was solved by adding forwardslashes to the urls.
That solved it for me !
Full example for a single virtual host file. I have several, one for each domain and subdomain.
您需要删除“ProxyPass”和“ProxyPassReverse”条目,除非您确实想代理某些内容。如果jboss AS位于另一台服务器上,那么您需要保留代理条目,但在我看来,如果内容位于一台机器上而不是多台机器上,您可能会变得太困难。
如果您希望一台服务器使用不同的基本文件夹作为 2 个不同域的根目录,则需要通过指定 DocumentRoot 参数来配置这 2 个域。
例如,如果我想在一台计算机上托管 google.com 和 yahoo.com,我的虚拟主机条目将包含:
然后,每台服务器的根目录将分别位于 google 文件夹和 yahoo 文件夹中。
如果您尝试代理一台完全不同的机器,那么以下内容应该有效:
您的条目具体没有多大意义。我认为它应该看起来像:
You need to remove the "ProxyPass" and "ProxyPassReverse" entries, unless you really are trying to proxy something. If the jboss AS is on another server, then you need to retain the proxy entries, but it looks to me like you might be making it too difficult if the content is on one machine and not multiples.
If you want one server to use different base folders as the root for 2 different domains, then you would need to configure the 2 domains by specifying the DocumentRoot parameter.
for example, if I wanted to host google.com and yahoo.com on one computer, my virtualhost entries would contain:
Then, your root directories for each server will go in the google folder and the yahoo folder, respectively.
If you are trying to proxy a completely different machine, then the following should work:
Your entry specifically doesn't make much sense. I think it should look like: