How to configure reverse proxy on Windows IIS

Guster
3 min readJun 8, 2020

--

Photo by Thomas Jensen on Unsplash

Much like Nginx, IIS is a web server on Windows that allows you configure to serve different kinds of purpose. From serving static files, to hosting a php application directly using, etc.

But when it comes to reverse proxy, Windows IIS is not as straight forward as Nginx. This article will show you how to setup a reverse proxy in a Windows IIS server.

Step 1. Install Routing Extensions

By default, IIS does not come with reverse proxy routing capability. To enable it, we need to manually install certain extensions first. Click the links below to download & install the extensions.

  1. Application request routing extensions
  2. URL rewrite extension

After installing the extensions, you should see an option URL Rewrite added to the IIS dashboard under Default Web Site.

Step 2. Add a reverse proxy rule

Now, click inside URL Rewrite option. Right toolbar > Select Actions > Add Rule(s)… > Inbound rules > Blank rule or Reverse Proxy rule. You should see something like this:

  • Pattern — URL pattern in regex form to match for reverse proxy routing
  • Conditions — (Optional) Extra conditions to complement Pattern
  • Server variables — (Optional) Add custom server variables if necessary.
  • Action — Action to perform if the URL is matched
  • Rewrite URL — URL to route to if matched. Eg. route to a local service running port 8080 (http://localhost:8080)

Note: Pattern uses regular expression format

In Pattern, make sure to match property the url for reverse routing. If it is to match all, simply set pattern as (.*).

Everything inside Pattern wrapped with parentheses can be referenced later in Rewrite URL box in sequence ({R:1}, {R:2}, etc). {R:0} refers to the entire url.

For example in the image above, request like http://api.myserver.com/myapi/auth/login will be routed to http://localhost:8080 as http://localhost:8080/auth/login.

The following variables will be created:

  • {R:0}myapi/api/login
  • {R:1}auth/login

Now, follow the configuration like in the image above and modify the Pattern and Rewrite URL accordingly.

Once you have done. Click Apply at the right toolbar to apply the changes.

Step 3. Enable Proxy settings in IIS

Finally, we need to enable IIS proxy settings. It’s not on by default.

Follow the steps below.

  • Click the root level of connection at the left toolbar:
  • Select Application Request Routing Cache option
  • At the right toolbar, select Server Proxy Settings…
  • Check Enable proxy

Conclusion

And that’s all you need to enable reverse proxy routing in Windows IIS.

Have fun.

--

--