我已经设置了2个apache服务器.一个在端口80上,另一个在端口8077上.我想通过反向代理在8077上查看服务器上的所有内容.目前我有:
ProxyPreserveHost Off
ProxyHTMLInterp On
ProxyPass /translate/ http://www.example.com:8077/
ProxyPassReverse /translate/ http://www.example.com:8077/
ProxyHTMLURLMap / /translate/
Run Code Online (Sandbox Code Playgroud)
这允许我到达网站的初始页面,但图像,CSS和其他页面的链接不起作用.
例如,html中的css显示为
/css/style.css
Run Code Online (Sandbox Code Playgroud)
我真正希望它在哪里
/translate/css/style.css
Run Code Online (Sandbox Code Playgroud)
它从8077服务器获取文件.如何使用当前设置才能使其正常工作?
我正在尝试在我的 Web 服务器上进行一些测试,以确保反向代理在将其放入实时环境之前按预期工作,但是我遇到了 mod_proxy 和 mod_proxy_html 的一些问题。
我有 2 个虚拟主机,1 个在端口 80 上,1 个在端口 8080 上。我的目标是让 www.example.com/path/ 的传入请求进入端口 80,并反向代理到端口 8080。
这是我的虚拟主机设置:
<VirtualHost *:8080>
ServerName www.example.com:8080
DocumentRoot /var/www/html/test
RewriteEngine On
RewriteCond %{REQUEST_URI} !^.*test
RewriteRule ^/?(.*) http://127.0.0.1:8080/test.html [R=301,L]
</VirtualHost>
<VirtualHost *:80>
ServerName www.example.com
ProxyHTMLEnable On
ProxyHTMLInterp On
ProxyPreserveHost Off
ProxyPass /path/ http://127.0.0.1:8080/
ProxyPassReverse /path/ http://127.0.0.1:8080/
ProxyHTMLURLMap http://127.0.0.1:8080/ /path/
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
我的 /var/www/html/test 有 2 个文件 index.html 和 test.html
test.html 内容是:
<HTML>
<BODY>
<a href="http://127.0.0.1:8080/index.html">TEST</a>
</BODY>
</HTML>
Run Code Online (Sandbox Code Playgroud)
转到 www.example.com/path/ 成功被代理并重定向到 www.example.com/path/test.html,但页面上的链接仍指向 127.0.0.1。
httpd -M …