gabriel giovanini
gabriel giovanini

Reputation: 189

Reverse proxy apache for TeamCity

I need to redirect a cname to a port.

I have Teamcity running on my server (at port 8111), I want to make teamcity.mydomain.com be redirected to mydomain.com:8111. So I will just need to type teamcity.mydomain.com to get into teamcity server.

I have read that reverse proxy from apache would do it for me, but so far I could not get it setup correctly.

ps.: it works when I do mydomain.com:8111.

Upvotes: 0

Views: 428

Answers (2)

Ben Richards
Ben Richards

Reputation: 3575

If you are running on Windows, and have IIS installed you can do this with IIS by installing the Application Request Routing module, and the Rewrite module. Once you do that, here is are the rewrite rules for your web.config. This rewrites all request for http://example.com to http://example.com:8080.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
    <rewrite>
        <rules>
            <rule name="CIReverseProxyInboundRule" stopProcessing="true">
                <match url="(.*)" />
                <action type="Rewrite" url="http://example.com:8080/{R:1}" />
                <conditions logicalGrouping="MatchAny">
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                </conditions>
            </rule>
        </rules>
        <outboundRules>
            <rule name="CIReverseProxyOutboundRule" preCondition="ResponseIsHtml1">
                <match filterByTags="A, Form, Img" pattern="^http(s)?://example.com:8080/(.*)" />
                <action type="Rewrite" value="http{R:1}://example.com/{R:2}" />
            </rule>
            <preConditions>
                <preCondition name="ResponseIsHtml1">
                    <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
                </preCondition>
            </preConditions>
        </outboundRules>
    </rewrite>
</system.webServer>
</configuration>

Upvotes: 0

Ddave
Ddave

Reputation: 26

I think something like this should work:

ProxyPass / http://example.org:8111/
ProxyPassReverse / http://example.org:8111/
ProxyPreserveHost On

Make sure mod_proxy is enabled to.

Upvotes: 1

Related Questions