You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Apache反向代理在443端口虚拟主机正常工作,但80端口无法生效的问题求助

Apache反向代理在443端口虚拟主机正常工作,但80端口无法生效的问题求助

各位好,我最近配置Apache反向代理时遇到了一个头疼的问题,想请大家帮忙分析下。

为了避免重复写反向代理规则,我定义了一个<Macro>来给80和443端口的虚拟主机共享配置,具体代码如下:

<Macro revproxies>
  ProxyPass "/index.html"               "http://internal-webserver/index.html"
  ProxyPassReverse "/index.html"        "http://internal-webserver/index.html"
  # 还有其他很多类似的反向代理规则
</Macro>

<VirtualHost *:80>
  ServerName www.example.com
  ServerAlias external-webserver
  DocumentRoot /var/www
  CustomLog /var/log/apache2/www.example.com.log combined
  Use revproxies
</VirtualHost>

<VirtualHost *:443>
  ServerName www.example.com
  ServerAlias external-webserver
  DocumentRoot /var/www
  SSLEngine on
  CustomLog /var/log/apache2/www.example.com.log combined
  Use revproxies
</VirtualHost>

现在的情况特别奇怪:用HTTPS(443端口)访问/index.html时,能正常通过反向代理拿到internal-webserver的页面;但用HTTP(80端口)访问同一个路径时,得到的却是Apache自动生成的默认页面,完全没走反向代理。

我核对了好几遍两个虚拟主机的配置,都已经引用了revproxies这个Macro,DocumentRoot的设置也完全一样,可就是找不到80端口反向代理失效的原因,有没有大佬能给点思路呀?

备注:内容来源于stack exchange,提问作者Kaz

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.16 08:33:06