Skip to content

Instantly share code, notes, and snippets.

@dario-l
Forked from jrgcubano/IISproxyToTeamCitySteps.txt
Created December 17, 2022 23:45
Show Gist options
  • Save dario-l/c9464609543b2c84b796201f8cb85f5d to your computer and use it in GitHub Desktop.
Save dario-l/c9464609543b2c84b796201f8cb85f5d to your computer and use it in GitHub Desktop.
Proxy using IIS to TeamCity site
Request:
Proxy to teamcity. Use a proxy in IIS and redirect "input" to "output".
Ideas:
http://jonalb.com/post/2010/10/23/TeamCity-On-Port-80-In-IIS.aspx
http://www.wrapcode.com/infrastructure/configure-reverse-proxy-with-url-rewrite-and-arr-for-iis/
Solution:
- Create an empty site in IIS
(Powershell) New-Item iis:\Sites\ci-bindings @{protocol="http";bindingInformation=":6500:ci"} -physicalPath C:\inetpub\wwwroot\ci
- Installs in IIS needed addins for ARR (Application request routing), using Mwpi (Microsoft Web Platform installer)
- Activate the use of proxys settings in the server
- Edit site "web.config" and add the next "input" and "output" rules to redirect all requests to the site of teamcity. You can do this manually to:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Inbound Rule">
<match url="(.*)" />
<conditions>
<add input="{CACHE_URL}" pattern="^(https?)://" />
</conditions>
<serverVariables>
<set name="HTTP_ACCEPT_ENCODING" value="True" />
</serverVariables>
<action type="Rewrite" url="http://localhost:6000/{R:1}" logRewrittenUrl="true" />
</rule>
</rules>
<outboundRules>
<rule name="Outbond" preCondition="ResponseIsHtml1">
<match filterByTags="A, Area, Base, Form, Frame, Img, Input, Link, Script" pattern="^http(s)?://localhost:6000/(.*)" />
<action type="Rewrite" value="{R:1}" />
</rule>
<preConditions>
<preCondition name="ResponseIsHtml1">
<add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
</preCondition>
</preConditions>
</outboundRules>
</rewrite>
</system.webServer>
</configuration>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment