Created
March 12, 2017 22:55
-
-
Save motowilliams/af7e46536c857cb30ccdc06016cc90d0 to your computer and use it in GitHub Desktop.
Adds a rule to proxy yourhost.example.com to localhost:yourportnumber with IIS Url Rewrite
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param ( | |
[string]$domain, | |
[string]$hostName, | |
[string]$port | |
) | |
$ruleName = "$hostName-inbound" | |
$publicHost = "$hostName.$domain" | |
$privateHost = "http://localhost:$port/{R:1}" | |
$path = "MACHINE/WEBROOT/APPHOST/Default Web Site" | |
Add-WebConfigurationProperty -pspath $path -filter "system.webServer/rewrite/rules" -name "." -value @{name=$ruleName;stopProcessing='True'} | |
Set-WebConfigurationProperty -pspath $path -filter "system.webServer/rewrite/rules/rule[@name='$hostName-inbound']/match" -name "url" -value "(.*)" | |
Add-WebConfigurationProperty -pspath $path -filter "system.webServer/rewrite/rules/rule[@name='$hostName-inbound']/conditions" -name "." -value @{input='{HTTP_POST}';pattern=$publicHost} | |
Set-WebConfigurationProperty -pspath $path -filter "system.webServer/rewrite/rules/rule[@name='$hostName-inbound']/action" -name "type" -value "Rewrite" | |
Set-WebConfigurationProperty -pspath $path -filter "system.webServer/rewrite/rules/rule[@name='$hostName-inbound']/action" -name "url" -value $privateHost |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment