Proxy an intranet, or other, server’s content through a different webserver. Say you have an intranet (internal) server whose content you want exposed to the public internet without actually giving it a public IP. You can use the following rewrite rule on a public server to proxy requests to the private server.

Proxy Using HTTP Protocol

To create the reverse proxy, we need to combine the following rewrite rule with the Application Request Routing module in IIS on the server which will act as the proxy.

First, check the ‘Enable Proxy’ checkbox in the Application Request Routing feature in IIS Manager.

Then add the following rule to web.config’s <rules> section:

<system.webServer>
	<rewrite>
		<rules>
			<rule name="Proxy Intranet Server">
				<match url="(.*)" />
				<action type="Rewrite" url="http://your-internal-servername/{R:1}" />
			</rule>
		</rules>
	</rewrite>
</system.webServer>

This would cause all requests to be proxied to the ‘your-internal-servername’ server using the HTTP protocol. You could also opt to connect with the proxied server using the HTTPS protocol by simply modifying the action’s url attribute.

Why Lose Memories?

Proxy Using Same Protocol As Request

You can also choose to proxy the requests using the same protocol as the original request. To do so, use the following rule instead:

<system.webServer>
	<rewrite>
		<rules>
			<rule name="Proxy">
				<match url="(.*)" />
				<conditions>
					<add input="{CACHE_URL}" pattern="^(https?)://" />
				</conditions>
				<action type="Rewrite" url="{C:1}://your-internal-servername/{R:1}" />
			</rule>
		</rules>
	</rewrite>
</system.webServer>

This would cause all requests to be proxied to the ‘your-internal-servername’ server using the original request’s protocol, so inbound HTTP connections will be proxied as HTTP to the internal server, and HTTPS will be proxied as HTTPS.