Apache反向代理访问目录时自动重定向至虚拟机本地IP的问题求助
Apache反向代理访问目录时自动重定向至虚拟机本地IP的问题求助
大家好,我最近在Apache反向代理的配置上卡壳了,折腾好几天都没找到问题所在,想请各位大佬帮忙分析一下。
我的环境情况:
- 一台Proxmox服务器,只有一个公网IP,上面运行着多台虚拟机
- Proxmox主机上部署了Apache,作为反向代理将外部请求转发到内部虚拟机
- 虚拟机上也运行着Apache,负责把请求导向对应的Web应用文档根
现在遇到的核心问题是:当我访问URL中某个实际存在的目录时(比如https://example.com/admin),Apache会自动把请求重定向到虚拟机的本地IP,也就是变成http://10.10.10.101/admin,这完全不符合预期,我需要它始终保持在公网域名上。
下面是我的具体配置信息:
Proxmox主机的Apache配置
<IfModule mod_ssl.c> <VirtualHost *:443> ServerAdmin info@example.com ServerName www.example.com ServerAlias www.example.com SSLProxyEngine On SSLProxyVerify none SSLProxyCheckPeerCN off SSLProxyCheckPeerName off SSLProxyCheckPeerExpire off ProxyPreserveHost On ProxyPass / http://10.10.10.101:80/ ProxyPassReverse / http://10.10.10.101:80/ Header add "Host" "www.example.com" RequestHeader set "Host" "www.example.com" Include /etc/letsencrypt/options-ssl-apache.conf SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem </VirtualHost> </IfModule>
虚拟机的Apache配置
<VirtualHost *:80> ServerAdmin info@example.com ServerName www.example.com ServerAlias www.example.com Header add "Host" "www.example.com" RequestHeader set "Host" "www.example.com" DocumentRoot /var/www/www.example/current/ ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined <Directory /var/www/www.example/current> Options +FollowSymLinks -Indexes AllowOverride All Require all granted </Directory> </VirtualHost>
已经花了好几天时间排查,但还是没找到问题根源,希望各位能给我一些思路或者解决方案,谢谢大家!
备注:内容来源于stack exchange,提问作者xtrose Media Studio




