javascript - IIS Reverse Proxy to Different Server - Stack Overflow

I am trying to figure out if its possible to do a Reverse Proxy in IIS that actually hit a different we

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>

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>
Share Improve this question asked Apr 29, 2013 at 19:13 RobRob 11.5k10 gold badges40 silver badges56 bronze badges 6
  • So what's the question? – Steven V Commented Apr 29, 2013 at 19:18
  • @StevenVondruska Well... I need to find out if its possible to use Reverse Proxy to call a different server ip and if it is, how to do it. – Rob Commented Apr 29, 2013 at 19:37
  • Do you have Application Request Routing (AAR) installed in IIS? – Steven V Commented Apr 29, 2013 at 19:44
  • 1 Then what you have written should work. Just change <action type="Rewrite" url="http://*IP HERE*:*PORT HERE*/{R:1}" /> and then have your Javascript issue a HTTP GET/POST to /name/*path to remote server*. – Steven V Commented Apr 29, 2013 at 20:16
  • @StevenVondruska I am copying your answer to an actual answer below. Please let me know if you would like to answer it yourself and I will remove my answer. – Codeman Commented Apr 29, 2013 at 22:48
 |  Show 1 more ment

1 Answer 1

Reset to default 7

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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742300682a4417972.html

相关推荐

  • javascript - IIS Reverse Proxy to Different Server - Stack Overflow

    I am trying to figure out if its possible to do a Reverse Proxy in IIS that actually hit a different we

    17小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信