TeamCity 的反向代理 apache

Reverse proxy apache for TeamCity

我需要将 cname 重定向到端口。

我的服务器上有 Teamcity 运行(端口 8111),我想让 teamcity.mydomain.com 重定向到 mydomain.com:8111。所以我只需要输入 teamcity.mydomain.com 即可进入 teamcity 服务器。

我已经阅读过来自 apache 的反向代理可以为我做这件事,但到目前为止我无法正确设置它。

ps.: 当我做 mydomain.com:8111.

时有效

我认为这样的事情应该可行:

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

确保 mod_proxy 已启用。

如果您在 Windows 上 运行,并且安装了 IIS,则可以通过安装应用程序请求路由模块和重写模块来使用 IIS 执行此操作。完成后,这里是 web.config 的重写规则。这将重写 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>