Apache2反向代理重定向

时间:2015-03-24 15:53:31

标签: javascript apache rewrite reverse-proxy synology

我已配置Apache反向代理,以连接到我的Synology Nas,但它不起作用。并非所有查询都会正确重写到新网址。

这是我的代码:

<VirtualHost *:80>
ServerAdmin email@loclahost   
ServerName server.fritz.box

ProxyHTMLEnable On

ProxyPass        /external/  http://192.168.178.99:5000/ 
ProxyPassReverse  /external/ http://192.168.178.99:5000/ 


</VirtualHost>

浏览器中仅显示页面名称和徽标,而不显示网站。

Probelm是代理不会重写脚本:

<div id="sds-login-dialog-form" style="position: absolute; top: -10000px; left: -10000px;"><form id="login-form" class="x-plain-body" method="POST" action="login.cgi" target="login_iframe" onsubmit="return true;"><input type="text" id="login_username" name="username" maxlength="256" /><input type="password" id="login_passwd" name="passwd" maxlength="256" autocomplete="off" /><input type="text" id="login_otp" name="OTPcode" maxlength="8" autocomplete="off" /><input type="submit" id="login_submit" style="position: absolute; top: -10000px; left: -10000px;" tabindex="-1" /></form><iframe id="login_iframe" name="login_iframe" width="0" height="0" frameborder="0" style="display: none;"></iframe></div>
<div id="sds-apply-preview-form" style="position: absolute; top: -10000px; left: -10000px;"><form id="preview-form" class="x-plain-body" method="POST" action="modules/ControlPanel/modules/dsm.cgi" target="preview_iframe" onsubmit="return true;"><input type="submit" id="preview_submit" style="position: absolute; top: -10000px; left: -10000px;" tabindex="-1" /></form><iframe id="preview_iframe" name="preview_iframe" width="0" height="0" frameborder="0" style="display: none;"></iframe></div>
<script type="text/javascript" src="synodefs.cgi?v=1420615814"></script>
<script type="text/javascript" src="/scripts/uistrings.cgi?lang=ger&v=1427210921"></script>
<script type="text/javascript" src="/webfm/webUI/uistrings.cgi?lang=ger&v=1427210921"></script>
<script type="text/javascript" src="uistrings.cgi?lang=ger&v=1427210921"></script>
<script type="text/javascript" src="/scripts/prototype-1.6.1/prototype.js?v=1420615788"></script>
<script type="text/javascript" src="/scripts/ext-3/adapter/ext/ext-base.js?v=1420615788"></script>
<script type="text/javascript" src="/scripts/ext-3/ext-all.js?v=1420615788"></script>
<script type="text/javascript" src="/scripts/ext-3/ux/ux-all.js?v=1420615788"></script>
<script type="text/javascript" src="/scripts/scrollbar/flexcroll.js?v=1420615788"></script>
<script type="text/javascript" src="sds.js?v=1420615813"></script>

只有在链接开头没有/的Scrips才可以调用。

如何将它们重写为新网址? 我希望你能帮助我!

抱歉我的英文不好:)

祝福 西蒙

1 个答案:

答案 0 :(得分:0)

您可以使用类似于仅使用/ script /

代理文件的内容

ProxyPassMatch ^(/ scripts /.*)$ http://192.168.178.99:5000/

或者如果您想代理以/开头的所有内容,尽管这可能会导致其他问题

ProxyPassMatch ^(/。*)$ http://192.168.178.99:5000/