IIS反向代理到Apache
问题描述:
我有一个heckuva时间让这个工作。我已经按照这个网址的指示:IIS反向代理到Apache
一个简单的测试,我想代理请求在我的媒体目录任何东西(CSS,图像等)到同一目录上的单独主办。这里的配置:
<rewrite>
<rules>
<rule name="ReverseProxyInboundRule1" stopProcessing="true">
<match url="^(media/.*)" />
<conditions>
<add input="{CACHE_URL}" pattern="^(https?)://" />
</conditions>
<action type="Rewrite" url="{C:1}://mystatichost/{R:1}" />
</rule>
</rules>
</rewrite>
在我Default.master
我有一个形象的标签,像这样:
<img src="/media/img/homepage.jpg" />
但我不断收到404错误对于图像的要求。文件/media/img/homepage.jpg
明确存在于mystatichost
。我错过了什么/误解?
答
在我看来,你的正则表达式有一些奇怪的地方。您应该使用<match url="(media/.*)" />
而不是<match url="^(media/.*)" />
。否则,您的匹配只能从URL字符串的开始处开始,因为它始终以http
开头,所以永远不会起作用。
所以,长话短说,试试这个:
<rewrite>
<rules>
<rule name="ReverseProxyInboundRule1" stopProcessing="true">
<match url="(media/.*)" />
<conditions>
<add input="{CACHE_URL}" pattern="^(https?)://" />
</conditions>
<action type="Rewrite" url="{C:1}://mystatichost/{R:1}" />
</rule>
</rules>
</rewrite>
如果不工作,你需要HTTPS您的所有要求mystatichost?
也许你可以删除<conditions>
部分,然后设置<action type="Rewrite" url="http://mystatichost/{R:1}" />
。
祝你好运!
我还没有能够获得反向代理使用这种技术。你有没有管理它? URL重定向工作,但不能重写/反向代理。 – 2013-01-08 14:30:07