I am trying to automate deployment of our .NET 5 GenericHost services. As they have both a WebAPI and long-running processes, IMHO it makes sense to deploy them as Windows Services and then create a IIS site that acts as reverse proxy. In short:
Browser ---------------------> IIS site -----------------------> WindowsService
https:/somesite.com http://localhost:9001
My "only" problem in this setup is how to create the reverse-proxy IIS site using PowerShell. I have absolute zero experience with this part.
I have figured out, that the IIS Module for PowerShell must be used. But I can't see if it gives access to URL Rewrite 2
, which is the way I know how to do reverse proxy in IIS.
Anybody know about the right documentation for this?
CodePudding user response:
Yes, the PowerShell WebAdministration Module can be used to edit Rewrite configuration
Example to edit a global rule:
Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -filter "system.webServer/rewrite/globalRules/rule[@name='Test']/match" -name "url" -value "foobar"
I would use the Configuration Editor
in IIS Manager
to create the rules and then use the Generate Script
feature in the Actions pane to create a PowerShell script which you can then use elsewhere.