Skip to main content

此版本的 GitHub Enterprise 已停止服务 2022-10-12. 即使针对重大安全问题,也不会发布补丁。 为了获得更好的性能、更高的安全性和新功能,请升级到最新版本的 GitHub Enterprise。 如需升级帮助,请联系 GitHub Enterprise 支持

Using GitHub Enterprise Server with a load balancer

Use a load balancer in front of a single GitHub Enterprise Server instance or a pair of instances in a High Availability configuration.

About load balancers

负载均衡器设计使用网络设备将 Git 和 HTTP 流量引导至各个 GitHub Enterprise Server 设备。 您可以使用负载均衡器限制引导至设备的流量以确保安全,或者在没有 DNS 记录更改的情况下� �据需要重定向流量。 我们强烈建议使用支持 PROXY 协议的基于 TCP 负载均衡器。

对 GitHub Enterprise Server 主机名的 DNS 查询应解析为负载均衡器。 我们建议您启用子域隔离。 如果启用了子域隔离,另一个通配符记录 *.HOSTNAME 也应解析到负载均衡器。 有关详细信息,请参阅“启用子域隔离”。

Handling client connection information

Because client connections to GitHub Enterprise Server come from the load balancer, the client IP address can be lost.

如果您的负载均衡器可以支持 PROXY 协议,我们强烈建议您实施该协议。 如果不能提供 PROXY 支持,使用 X-Forwarded-For � �头也可以对 HTTP 和 HTTPS 端口进行负载均衡。

安全警告:启用了 PROXY 支持或 HTTP 转发时,重要的是确保没有外部流量可以直接到达 GitHub Enterprise Server 设备。 如果未能正确阻止外部流量,则源 IP 地址可能被伪� 。

警告:在负载均衡器上终止 HTTPS 连接时,从负载均衡器到 GitHub Enterprise Server 的请求也需要使用 HTTPS。 不支持降级到 HTTP 连接。

Enabling PROXY protocol support on your GitHub Enterprise Server instance

We strongly recommend enabling PROXY protocol support for both your instance and the load balancer. Use the instructions provided by your vendor to enable the PROXY protocol on your load balancer. For more information, see the PROXY protocol documentation.

注意:GitHub Enterprise Server 支持与 AWS 网络负载均衡器不兼容的 PROXY 协议 V1。 如果将 AWS 网络负载均衡器与 GitHub Enterprise Server 配合使用,请不要启用 PROXY 支持。

  1. 从 GitHub Enterprise Server 上的管理帐户任意页面的右上角,单击

    用于访问站点管理员设置的火箭图� �的屏幕截图

  2. 如果� 尚未在“站点管理员”页上,请在左上角单击“站点管理员”。

    “站点管理员”链接的屏幕截图

  3. 在左侧边� �中,单击“管理控制台”。 左侧边� �中的 管理控制台 选项卡

  4. 在左侧边� �中,单击“隐私”。 设置侧边� �中的“隐私”选项卡

  5. Under External load balancers, select Enable support for PROXY protocol. Checkbox to enable support for PROXY protocol

  6. 在左侧边� �下,单击“保存设置”。

    管理控制台 中的“保存设置”按钮的屏幕截图

    注意:保存 管理控制台 中的设置会重启系统服务,这可能会导致用户可察觉的停机时间。

  7. 等待配置运行完毕。

    配置实例

PROXY 协议 TCP 端口� 射

源端口目� �端口服务说明
2223通过 SSH 访问 Git
8081HTTP
443444HTTPS
80808081Management Console HTTP
84438444Management Console HTTPS
94189419Git

Enabling X-Forwarded-For support on your GitHub Enterprise Server instance

仅当 PROXY 协议不可用时才使用 X-Forwarded-For 协议。 X-Forwarded-For � �头仅适用于 HTTP 和 HTTPS。 基于 SSH 的 Git 连接报告的 IP 地址将显示负载均衡器 IP。

Warning: If you configure X-Forwarded-For support on your GitHub Enterprise Server instance and load balancer, you may not be able to connect to the 管理控制台. For more information, see "Error: "Your session has expired" for connections to the 管理控制台."

  1. 从 GitHub Enterprise Server 上的管理帐户任意页面的右上角,单击

    用于访问站点管理员设置的火箭图� �的屏幕截图

  2. 如果� 尚未在“站点管理员”页上,请在左上角单击“站点管理员”。

    “站点管理员”链接的屏幕截图

  3. 在左侧边� �中,单击“管理控制台”。 左侧边� �中的 管理控制台 选项卡

  4. 在左侧边� �中,单击“隐私”。 设置侧边� �中的“隐私”选项卡

  5. Under External load balancers, select Allow HTTP X-Forwarded-For header. Checkbox to allow the HTTP X-Forwarded-For header

  6. 在左侧边� �下,单击“保存设置”。

    管理控制台 中的“保存设置”按钮的屏幕截图

    注意:保存 管理控制台 中的设置会重启系统服务,这可能会导致用户可察觉的停机时间。

  7. 等待配置运行完毕。

    配置实例

协议 TCP 端口� 射,� 需 PROXY 支持即可使用

源端口目� �端口服务说明
2222通过 SSH 访问 Git
2525SMTP
8080HTTP
443443HTTPS
80808080Management Console HTTP
84438443Management Console HTTPS

Configuring health checks

Health checks allow a load balancer to stop sending traffic to a node that is not responding if a pre-configured check fails on that node. If the instance is offline due to maintenance or unexpected failure, the load balancer can display a status page. In a High Availability (HA) configuration, a load balancer can be used as part of a failover strategy. However, automatic failover of HA pairs is not supported. You must manually promote the replica instance before it will begin serving requests. For more information, see "Configuring GitHub Enterprise Server for High Availability."

配置负载均衡器以检查以下 URL 之一:

  • 如果已启用 HTTPS(默认),则检查 https://HOSTNAME/status
  • 如果已禁用 HTTPS(默认),则检查 http://HOSTNAME/status

如果节点运行正常并且可为最终用户的请求提供服务,则检查将返回状态代� � 200(正常)。

注意: 当设备处于维护模式时,https://HOSTNAME/status URL 将返回状态代� � 503(服务不可用)。 有关详细信息,请参阅“启用和安排维护模式”。

Troubleshooting connectivity through a load balancer

If you cannot connect to services on your GitHub Enterprise Server instance through a load balancer, you can review the following information to troubleshoot the problem.

Note: Always test changes to your network infrastructure and instance configuration in a staging environment. For more information, see "Setting up a staging instance."

Error: "Your session has expired" for connections to the 管理控制台

If you enable support for the X-Forwarded-For header on your instance and load balancer, you may not be able to access your instance's 管理控制台. For more information about the 管理控制台 and ports required for connections, see "Accessing the management console" and "Network ports."

If your GitHub Enterprise Server instance indicates that your session has expired when you connect to the 管理控制台 through a load balancer, try one of the following configurations on your load balancer.

For more information, refer to the documentation for your load balancer.

Live updates to issues and check runs not working

When your GitHub Enterprise Server instance is accessed via a load balancer or reverse proxy, expected live updates, such as new comments on issues and changes in notification badges or check run output, may not display until the page is refreshed. This is most common when the reverse proxy or load balancer is running in a layer 7 mode or does not support the required websocket protocol.

To enable live updates, you may need to reconfigure the load balancer or proxy. For more information, refer to the documentation for your load balancer.