apache 如何配置Apache来代理一个文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1561129/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to configure Apache to proxy exactly one file?
提问by scobi
(I must be dense - I just can't figure out the Apache documentation on how to do this.)
(我必须很密集 - 我只是无法弄清楚如何做到这一点的 Apache 文档。)
To speed up some swf development I'm doing, I want to have my local machine fetch my local swf when I browse to our studio's test website. Just the one local swf only - with the rest pulled from the test website.
为了加快我正在做的一些 swf 开发,我想让我的本地机器在我浏览我们工作室的测试网站时获取我的本地 swf。只有一个本地 swf - 其余的从测试网站中提取。
So I set up apache on port 80 with mod_proxy and proxy_http_module, then added an entry for HOSTS to say the test server is 127.0.0.1. What I need are the magical incantations to put in httpd.conf to say "every call requesting http://test/blahgoes to 10.1.1.whatever EXCEPT http://test/blah/foo.swfwhich goes to c:\proj\foo.swf".
所以我用 mod_proxy 和 proxy_http_module 在端口 80 上设置了 apache,然后为 HOSTS 添加了一个条目,说测试服务器是 127.0.0.1。我需要的是放在 httpd.conf 中的神奇咒语,以说“每个请求http://test/blah 的调用都转到 10.1.1.whatever 除了http://test/blah/foo.swf转到 c: \proj\foo.swf”。
Can someone help with this? Thank you.
有人可以帮忙吗?谢谢你。
采纳答案by Ben James
There is a simple syntax for disallowing a particular URL from proxying:
有一个简单的语法来禁止特定的 URL 代理:
ProxyPass /blah/foo.swf !
ProxyPass /blah http://10.1.1.whatever
回答by scobi
For the record here's what I ended up with, roughly:
为了记录,这是我最终得到的,大致是:
<VirtualHost *>
ServerName (testserver-dns)
ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass /path/to/swf !
ProxyPass / http://10.1.2.3/
ProxyPassReverse / http://10.1.2.3/
<Location />
Order allow,deny
Allow from all
</Location>
</VirtualHost>

