NGINX Configuration

GitLab makes use of an internal NGINX as a proxy to the services inside the tile. To ensure that client IPs are presented accurately to the service components, GitLab provides a method to add to the list of trusted proxies for the NGINX instance. GitLab prepopulate the list of trusted proxies with the addresses of the Pivotal Cloud Foundry (PCF) GoRouter addresses as a part of the tile, and provides a field to add additional trusted proxies that may be present as a part of the Infrastructure as a Service (IaaS) in use.

Throughout this document, GitLab mentions reverse proxies which is how Load Balancers route traffic to individual service instances. It is possible that your environment may have additional proxies that are not load balancers. Throughout this documentation, you can interchange “reverse proxy” with “load balancer.”

If this information is not provided, NGINX presents the addresses of the reverse proxies as that of the client. This can result in the RackAttack component of the GitLab instance behaving in a way that is in agreement with its design, but not as you intended or expected. If the addresses provided to RackAttack are that of the reverse proxies instead of the client, behaviors such as request throttling and failed authentication could occur based on the proxies and not the end client. This can result in spurious Access Forbidden (HTTP 403) responses from the server. When configured so that all layers of proxies are included and trusted in these settings, these erroneous behaviors do not occur.

Image of NGINX settings

Trusted Proxy Addresses

This field accepts a comma-separated list of IP addresses and CIDR notation. The values in this field should be complete 4-octet addresses, with or without CIDR notation.

Example Lists
192.168.10.18
192.168.10.18, 10.0.16.15, 10.0.16.23
192.168.10.1/24, 10.0.16.15, 130.211.0.0/22

Retrieve Addresses from Your IaaS

Depending on the IaaS in use, there may be one or more additional reverse proxies between your clients external to PCF and your GitLab instances. The location of these reverse proxies varies greatly between individual deployments. When collecting this information, tile administrators need to collect the necessary information from their infrastructure.

Google Cloud Platform

As a part of the PCF installation and configuration documentation for GCP, you will have created a Load Balancer. The IP addresses of these load balancer instances should be added to this list. There is a known subnet that these load balancers will be placed into (130.211.0.0/22), however you might want to be more specific. An excerpt from Google Cloud documentation below describes the complete subnet in which all GCP load balancers are placed:

Firewall rules

You must create a firewall rule that allows traffic from 130.211.0.0/22 and 35.191.0.0/16 to reach your instances. This rule allows traffic from both the load balancer and the health checker.

To collect the IP address of the front-end load balancer from the GCP console, do the following:

  1. Log in to the GCP console.

  2. Select the appropriate project used to install PCF from the project drop-down.

  3. From the Products & Services menu on the left of the page, under the Networking section, select Network services > Load balancing.

  4. Find the load balancer in the list and click to expand the information panel underneath its row.

    In that panel, the public IP address of the load balancer is listed under the “Frontend” section.

Amazon Web Services

As a part of the PCF installation and configuration documentation for AWS, you created a Web Load Balancer. Any subnet that a load balancer has been created inside should be added to the list of Trusted Proxy Addresses

vSphere

As a part of the PCF installation and configuration documentation for vSphere, you have configured either the Pivotal HAProxy Load Balancer or another. The IP addresses used here should be added to the list of Trusted Proxy Addresses.

Azure

  1. Log in to the Azure portal (portal.azure.com).

  2. Select the resource group PCF was installed in.

  3. In the overview section, filter all items by type, clear everything, and select Load Balancers.

  4. Click on the load balancer in the results list and the public IP address is listed in the overview section.

Create a pull request or raise an issue on the source for this page in GitHub