proxy - nginx 代理背后的 TeamCity

标签 proxy nginx url-rewriting teamcity

我正在尝试在 nginx 后面设置 TeamCity。我想要https://public.address.com/teamcity/ ...重定向到http://127.0.0.1:8111/ ...,但即使 nginx 成功完成此操作,登录页面也会返回如下所示的引用:

<script type="text/javascript" src="/res/-8762791360234593415.js?v=1305815890782"></script>

显然,这是不行的,并且摆弄 rootURL 设置(服务器配置中的服务器 URL:)不会使有什么区别。

如何在非根 URL 下的代理后面运行 TeamCity?

<小时/>

FWIW,这是我的 nginx 配置的相关部分:

location /teamcity/ {
    proxy_pass       http://127.0.0.1:8111/;
    proxy_redirect   http://127.0.0.1:8111/ https://$host/teamcity/;
}

最佳答案

我使用标准 Teamcity Windows 安装程序完成此操作,大概它可以在任何平台上运行。

更改 Teamcity 位置

根据comment by a JetBrains employee :

To change TeamCity address from http://server/ to http://server/teamcity/, rename the <TeamCity home>\webapps\ROOT directory to <TeamCity home>\webapps\teamcity.

另请注意,每次升级 Teamcity 时都需要重命名此目录。

代理配置

nginx 配置看起来像这样:

    location /teamcity/ {
            proxy_pass http://teamcity-server.domain.com/teamcity/;
    }

或者您可以使用 Apache(由于身份验证要求,我切换到 Apache):

    <Location /teamcity>
            ProxyPass http://teamcity-server.domain.com/teamcity
            ProxyPassReverse http://teamcity-server.domain.com/teamcity
    </Location>

重定向旧网址

我还创建了一个 <Teamcity home>\webapps\ROOT ,然后输入 index.jsp文件写入其中,重定向到新的 URL,以便旧链接继续工作(例如,如果有人访问 http://teamcity-server.domain.com,它会重定向到 http://teamcity-server.domain.com/teamcity ):

<!DOCTYPE html>
<html>
<head>
  <title>TeamCity</title>
  <meta http-equiv="refresh" content="0;url=/teamcity/overview.html"/>
</head>
<body>
  <!-- no content -->
</body>
</html>

您还可以在 nginx/apache 中进行重定向,但在 Teamcity 服务器上进行重定向意味着如果有人直接在 teamcity Web 服务器上(而不是通过您的代理)访问旧 URL,他们仍然会得到正确的重定向(而不是404)。

关于proxy - nginx 代理背后的 TeamCity,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6071426/

相关文章:

internet-explorer - 是否有支持带身份验证的 Socks5 的浏览器?

docker - 带有php链接的docker-compose.yml nginx

asp.net - 使用 ARR 的 IIS 反向代理存在目录级别问题

带有 urlencode 和 "&"错误的 PHP $_GET var

WPF 绑定(bind)到代理

java - 如何从 Java 使用 WinInet API?

python-3.x - 尝试将 Flask-socket 与 uwsgi 和 nginx 一起使用时经常出现 400 Bad Request 错误

php - 在 php 中创建包含用户名的用户友好 url

Java拦截HTTP请求

Django:行被删除后仍然显示 - 因为缓存?