大网数据广告活动
服务器运维问答

Apache Reverse Proxy for two web applications: One on localhost another on remote machine

· 52CE 我爱测

I've got two web applications: Jira and Mercurial. They used to be on the same server Dual Host but I've since moved Mercurial to Mercurial Host . Jira is still hosted on Dual Host . Dual Host has an Apache 2.2.22 server which us…

问题原文

原帖链接 · dosaki · CC BY-SA 3.0

I've got two web applications: Jira and Mercurial. They used to be on the same server Dual Host but I've since moved Mercurial to Mercurial Host. Jira is still hosted on Dual Host.

Dual Host has an Apache 2.2.22 server which used to host Mercurial but will now serve as the reverse proxy.

On my domain server, I've set up jira to point to Dual Host's IP and mercurial to point to Mercurial Host's IP.

People used to access Jira by going to http://dualhost:4040/ and Mercurial by going to http://dualhost/.

I've set up a reverse proxy to proxy requests for http://dualhost/ to http://mercurial/ (so that existing links to commits in various places). This is working fine with the configuration below:

<VirtualHost *:80>
    ServerName dualhost
    ProxyPreserveHost On

    ProxyPass / http://mercurial:80/
    ProxyPassReverse / http://mercurial:80/
</VirtualHost>

Now I wanted to proxy requests for http://jira to http://dualhost:4040 but I keep getting proxied to Mercurial.

The reason for this is that I want to move Jira to a new server at a later date and the sooner the URL is 'correct' the better.

I've set that rule to:

<VirtualHost jira:80>
    ServerName jira
    ProxyPreserveHost On

    ProxyPass / http://localhost:4040/
    ProxyPassReverse / http://localhost:4040/
</VirtualHost>

I'm looking at the Apache 2.2 documentation and this looks like it should work. What am I doing wrong?

已采纳解答

原帖链接 · André Fernandes · CC BY-SA 3.0

Try using <VirtualHost *:80> in your jira virtualhost configuration.

Virtualhost matching is order-sensitive, so if a <VirtualHost *:80> comes before a <VirtualHost jira:80>, the second will never match. This is also true if you're using multiple distinct conf.d/*.conf files, since apache loads those files in alphabetical order.

From your example one could assume you'd use files named conf.d/dualhost.conf and conf.d/jira.conf. Since dualhost comes alphabetically before jira, the second would never match.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-02-27)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。