IIS Reverse Proxy to Different Server

こ雲淡風輕ζ 提交于 2019-12-08 09:54:47

问题


I am trying to figure out if its possible to do a Reverse Proxy in IIS that actually hit a different web server end point. I have used it to traverse Ports on the same machine, but never to a different machine. The purpose of this is that I am writing a Javascript application that needs to connect to data on a different server and I am getting Same Origin errors.

Note: Unfortunately, changing the remote server and service to accept JSONP or CORS is not an option.

Here is the config for Port jumping using IIS Reverse Proxy

<system.webServer>      
        <rewrite>
            <rules>
                <rule name="Reverse Proxy to Different Port" stopProcessing="true">
                    <match url="^name/(.*)" />
                    <action type="Rewrite" url="http://localhost:5984/{R:1}" />
                </rule>
            </rules>
        </rewrite>
</system.webServer>

回答1:


To make this work, you need to have Application Request Routing (AAR) installed on the IIS server you want to act like the reverse proxy. After that, then add the following into the web.config:

<system.webServer>      
    <rewrite>
        <rules>
            <rule name="Reverse Proxy to Different Port" stopProcessing="true">
                <match url="^name/(.*)" />
                <action type="Rewrite" url="http://[hostname here]:[port number here]/{R:1}" />
            </rule>
        </rules>
    </rewrite>
</system.webServer>

This will redirect any request where the path starts with name/ to the other server. So if you're seeking /foo/bar on the remote server, you would need Javascript to request /name/foo/bar to the IIS server that has the reverse proxy configured.



来源:https://stackoverflow.com/questions/16286421/iis-reverse-proxy-to-different-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!