GitLab Pages administration

  • Tier: Free, Premium, Ultimate
  • Offering: GitLab Self-Managed

GitLab Pages provides static site hosting for GitLab projects and groups. Server administrators must configure Pages before users can access this feature. As an administrator, you can use GitLab Pages to:

  • Host static websites securely with custom domains and SSL/TLS certificates.
  • Turn on authentication to control access to Pages sites through GitLab permissions.
  • Scale deployments using object storage or network storage in multi-node environments.
  • Monitor and manage traffic with rate limiting and custom headers.
  • Support IPv4 and IPv6 addresses for all Pages sites.

The GitLab Pages daemon runs as a separate process and can be configured either on the same server as GitLab or on its own dedicated infrastructure. For user documentation, see GitLab Pages.

This guide is for Linux package installations. For self-compiled installations, see GitLab Pages administration for self-compiled installations.

GitLab Pages daemon

GitLab Pages uses the GitLab Pages daemon, a basic HTTP server written in Go that can listen on an external IP address and provide support for custom domains and custom certificates. It supports dynamic certificates through Server Name Indication (SNI) and exposes pages using HTTP2 by default.

For more information, see the README.

When used with custom domains, the Pages daemon must listen on ports 80 or 443. This is not required for wildcard domains.

You can run the Pages daemon:

  • On the same server as GitLab, listening on a secondary IP.
  • On a separate server. The Pages path must also be present on the server where the Pages daemon is installed, so you must share it over the network.
  • On the same server as GitLab, listening on the same IP but on different ports. In this case, you must proxy the traffic with a load balancer. For HTTPS, use TCP load balancing. If you use TLS termination (HTTPS load balancing), pages cannot be served with user-provided certificates. For HTTP, either HTTP or TCP load balancing is acceptable.

The following sections assume the first option. If you are not supporting custom domains, a secondary IP is not needed.

Prerequisites

This section describes the prerequisites for configuring GitLab Pages.

If your GitLab instance and the Pages daemon are deployed in a private network or behind a firewall, your GitLab Pages websites are only accessible to devices and users with access to the private network.

Before configuring GitLab Pages, you must:

  1. Have a domain for Pages that is not a subdomain of your GitLab instance domain.

    You should run GitLab Pages under a different hostname than GitLab to prevent XSS attacks.

    GitLab domainPages domainDoes it work?
    example.comexample.iocheck-sm
    example.compages.example.comNo 1
    gitlab.example.compages.example.comcheck-sm
  2. Optional but recommended. Turn on instance runners so that your users do not have to bring their own.

Add the domain to the Public Suffix List

The Public Suffix List is used by browsers to decide how to treat subdomains. If your GitLab instance allows members of the public to create GitLab Pages sites, it also allows those users to create subdomains on the pages domain (example.io). Adding the domain to the Public Suffix List prevents browsers from accepting supercookies, among other things.

To submit your GitLab Pages subdomain, see submit amendments to the Public Suffix List. For example, if your domain is example.io, you should request that example.io is added to the Public Suffix List. GitLab.com added gitlab.io in 2016.

Configure wildcard domains

Each site gets its own subdomain (for example, <namespace>.example.io/<project_slug>). This subdomain requires a wildcard DNS record (*.example.io) and is the recommended setup for most instances.

DNS configuration for wildcard domains

GitLab Pages runs on its own virtual host. In your DNS server or provider, add a wildcard DNS A record pointing to the host that GitLab runs on. For example:

*.example.io. 1800 IN A    192.0.2.1
*.example.io. 1800 IN AAAA 2001:db8::1

Where example.io is the domain GitLab Pages is served from, 192.0.2.1 is the IPv4 address of your GitLab instance, and 2001:db8::1 is the IPv6 address. If you do not have IPv6, you can omit the AAAA record.

Wildcard domains without TLS

This configuration is the minimum setup to use GitLab Pages and serves as the foundation for all other setups. In this configuration:

  • NGINX proxies all requests to the GitLab Pages daemon.
  • The GitLab Pages daemon does not listen directly to the public internet.

Prerequisites:

To configure GitLab Pages to use wildcard domains:

  1. Set the external URL for GitLab Pages in /etc/gitlab/gitlab.rb:

    ruby
    external_url "http://example.com" # external_url here is only for reference
    pages_external_url 'http://example.io' # Important: not a subdomain of external_url, so cannot be http://pages.example.com
  2. Save the file and reconfigure GitLab for the changes to take effect.

The resulting URL scheme is http://<namespace>.example.io/<project_slug>.

For an overview, see the enable GitLab Pages for GitLab CE and EE video.

Wildcard domains with TLS support

NGINX proxies all requests to the daemon. The Pages daemon does not listen to the public internet.

Only one wildcard can be assigned to an instance.

Prerequisites:

  • You have configured wildcard DNS.
  • You have a TLS certificate. It can be a wildcard certificate or any other type meeting the requirements.

To configure wildcard domains with TLS support:

  1. Place the wildcard TLS certificate for *.example.io and the key inside /etc/gitlab/ssl.

  2. In /etc/gitlab/gitlab.rb, specify the following configuration:

    ruby
    external_url "https://example.com" # external_url here is only for reference
    pages_external_url 'https://example.io' # Important: not a subdomain of external_url, so cannot be https://pages.example.com
    
    pages_nginx['redirect_http_to_https'] = true
  3. If your certificate and key are not named example.io.crt and example.io.key, add the full paths:

    ruby
    pages_nginx['ssl_certificate'] = "/etc/gitlab/ssl/pages-nginx.crt"
    pages_nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/pages-nginx.key"
  4. Save the file and reconfigure GitLab for the changes to take effect.

  5. If you’re using access control, update the redirect URI in the GitLab Pages system OAuth application to use the HTTPS protocol.

The resulting URL scheme is https://<namespace>.example.io/<project_slug>.

GitLab Pages does not update the OAuth application if changes are made to the redirect URI. Before you reconfigure, remove the gitlab_pages section from /etc/gitlab/gitlab-secrets.json, then run gitlab-ctl reconfigure. For more information, see GitLab Pages does not regenerate OAuth.

Wildcard domains with TLS-terminating load balancer

Use this setup when installing a GitLab POC on Amazon Web Services. This setup includes a TLS-terminating classic load balancer that listens for HTTPS connections, manages TLS certificates, and forwards HTTP traffic to the instance.

Prerequisites:

To configure wildcard domains with a TLS-terminating load balancer:

  1. In /etc/gitlab/gitlab.rb, specify the following configuration:

    ruby
    external_url "https://example.com" # external_url here is only for reference
    pages_external_url 'https://example.io' # Important: not a subdomain of external_url, so cannot be https://pages.example.com
    
    pages_nginx['enable'] = true
    pages_nginx['listen_port'] = 80
    pages_nginx['listen_https'] = false
    pages_nginx['redirect_http_to_https'] = true
  2. Save the file and reconfigure GitLab for the changes to take effect.

The resulting URL scheme is https://<namespace>.example.io/<project_slug>.

Configure single-domain sites

All sites share one domain, with the namespace and project slug as path segments (for example, example.io/<namespace>/<project_slug>). This domain requires only a single DNS A record.

DNS configuration for single-domain sites

To configure GitLab Pages DNS for single-domain sites without wildcard DNS:

  1. Turn on the GitLab Pages flag for this feature by adding gitlab_pages['namespace_in_path'] = true to /etc/gitlab/gitlab.rb.

  2. In your DNS provider, add entries for example.io. Replace example.io with your domain name, and 192.0.0.0 with the IPv4 address of your instance:

    example.io          1800 IN A    192.0.0.0
  3. Optional. If your GitLab instance has an IPv6 address, add entries for it. Replace example.io with your domain name, and 2001:db8::1 with the IPv6 address of your instance:

    example.io          1800 IN AAAA 2001:db8::1

    example.io is the domain GitLab Pages is served from.

Single-domain sites without TLS

This configuration is the minimum setup to use single-domain sites and serves as the foundation for all other single-domain setups. In this configuration:

  • NGINX proxies all requests to the GitLab Pages daemon.
  • The GitLab Pages daemon does not listen directly to the public internet.

Prerequisites:

To configure GitLab Pages to use single-domain sites:

  1. In /etc/gitlab/gitlab.rb, set the external URL for GitLab Pages, and turn on the feature:

    ruby
    external_url "http://example.com" # Swap out this URL for your own
    pages_external_url 'http://example.io' # Important: not a subdomain of external_url, so cannot be http://pages.example.com
    
    # Set this flag to turn on this feature
    gitlab_pages['namespace_in_path'] = true
  2. Save the file and reconfigure GitLab for the changes to take effect.

The resulting URL scheme is http://example.io/<namespace>/<project_slug>.

GitLab Pages supports only one URL scheme at a time: wildcard domains or single-domain sites. If you turn on namespace_in_path, existing GitLab Pages websites are accessible only as single-domain sites.

Single-domain sites with TLS support

In this configuration, NGINX proxies all requests to the daemon. The GitLab Pages daemon does not listen to the public internet.

Prerequisites:

  • You have configured DNS for single-domain sites.
  • You have a TLS certificate that covers your domain (like example.io).

To configure single-domain sites with TLS support:

  1. Add your TLS certificate and key to /etc/gitlab/ssl.

  2. In /etc/gitlab/gitlab.rb, set the external URL for GitLab Pages and turn on the feature:

    ruby
    external_url "https://example.com" # Swap out this URL for your own
    pages_external_url 'https://example.io' # Important: not a subdomain of external_url, so cannot be https://pages.example.com
    
    pages_nginx['redirect_http_to_https'] = true
    
    # Set this flag to turn on this feature
    gitlab_pages['namespace_in_path'] = true
  3. If your TLS certificate or key files have different names than example.io.crt and example.io.key, add the full paths:

    ruby
    pages_nginx['ssl_certificate'] = "/etc/gitlab/ssl/pages-nginx.crt"
    pages_nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/pages-nginx.key"
  4. If you’re using access control, update the redirect URI in the GitLab Pages system OAuth application to use the HTTPS protocol.

    GitLab Pages does not update the OAuth application, and the default auth_redirect_uri is updated to https://example.io/projects/auth. Before you reconfigure, remove the gitlab_pages section from /etc/gitlab/gitlab-secrets.json, then run gitlab-ctl reconfigure. For more information, see GitLab Pages does not regenerate OAuth.

  5. Save the file and reconfigure GitLab for the changes to take effect.

The resulting URL scheme is https://example.io/<namespace>/<project_slug>.

GitLab Pages supports only one URL scheme at a time: wildcard domains or single-domain sites. If you turn on namespace_in_path, existing GitLab Pages websites are accessible only as single-domain sites.

Configure custom domains

By default, GitLab Pages sites are served on a subdomain of the Pages root domain, for example, namespace.example.io/project. To configure a custom domain for a Pages site, add a CNAME DNS record that points your own domain (for example, example-custom-site-here.com) to GitLab Pages.

If you only need the default *.example.io subdomain URLs, you don’t need to configure custom domain support.

You can configure custom domains with or without TLS certificates. In either case, you need a secondary IP. If you have both IPv6 and IPv4 addresses, you can use them both.

DNS configuration for custom domains

If you need custom domain support, all subdomains of the Pages root domain must point to the secondary IP dedicated to the Pages daemon. Without this configuration, users cannot use CNAME records to point their custom domains to their GitLab Pages.

For example:

example.com   1800 IN A    192.0.2.1
*.example.io. 1800 IN A    192.0.2.2

This example contains:

  • example.com: The GitLab domain.
  • example.io: The domain GitLab Pages is served from.
  • 192.0.2.1: The primary IP of your GitLab instance.
  • 192.0.2.2: The secondary IP dedicated to GitLab Pages. It must differ from the primary IP.

Do not use the GitLab domain to serve user pages. For more information, see the prerequisites.

Custom domains without TLS

In this configuration, the Pages daemon is running and NGINX proxies requests to it, but the daemon can also receive requests from the public internet. Custom domains are supported without TLS.

Prerequisites:

To configure custom domains:

  1. In /etc/gitlab/gitlab.rb, specify the following configuration:

    ruby
    external_url "http://example.com" # external_url here is only for reference
    pages_external_url 'http://example.io' # Important: not a subdomain of external_url, so cannot be http://pages.example.com
    nginx['listen_addresses'] = ['192.0.2.1'] # The primary IP of the GitLab instance
    pages_nginx['enable'] = false
    gitlab_pages['external_http'] = ['192.0.2.2:80', '[2001:db8::2]:80'] # The secondary IPs for the GitLab Pages daemon
    gitlab_pages['custom_domain_mode'] = 'http' # Enable custom domain

    If you do not have IPv6, omit the IPv6 address.

  2. Save the file and reconfigure GitLab for the changes to take effect.

The resulting URL schemes are http://<namespace>.example.io/<project_slug> and http://custom-domain.com.

Custom domains with TLS support

In this configuration, the Pages daemon is running and NGINX proxies requests to it, but the daemon can also receive requests from the public internet. Custom domains and TLS are supported.

Prerequisites:

  • Configured wildcard DNS.
  • A TLS certificate. It can be a wildcard certificate or any other type meeting the requirements.
  • A secondary IP.

To configure custom domains with TLS support:

  1. Place the wildcard TLS certificate for *.example.io and the key inside /etc/gitlab/ssl.

  2. In /etc/gitlab/gitlab.rb, specify the following configuration:

    ruby
    external_url "https://example.com" # external_url here is only for reference
    pages_external_url 'https://example.io' # Important: not a subdomain of external_url, so cannot be https://pages.example.com
    nginx['listen_addresses'] = ['192.0.2.1'] # The primary IP of the GitLab instance
    pages_nginx['enable'] = false
    gitlab_pages['external_http'] = ['192.0.2.2:80', '[2001:db8::2]:80'] # The secondary IPs for the GitLab Pages daemon
    gitlab_pages['external_https'] = ['192.0.2.2:443', '[2001:db8::2]:443'] # The secondary IPs for the GitLab Pages daemon
    gitlab_pages['custom_domain_mode'] = 'https' # Enable custom domain
    # Redirect pages from HTTP to HTTPS
    gitlab_pages['redirect_http'] = true

    If you do not have IPv6, omit the IPv6 address.

  3. If your certificate and key are not named example.io.crt and example.io.key, add the full paths:

    ruby
    gitlab_pages['cert'] = "/etc/gitlab/ssl/example.io.crt"
    gitlab_pages['cert_key'] = "/etc/gitlab/ssl/example.io.key"
  4. Save the file and reconfigure GitLab for the changes to take effect.

  5. If you’re using access control, edit the redirect URI in the GitLab Pages system OAuth application to use the HTTPS protocol.

Custom domain verification

To prevent malicious users from hijacking domains that do not belong to them, GitLab supports custom domain verification. When adding a custom domain, users must prove they own it by adding a GitLab-controlled verification code to the DNS records for that domain.

Turning off domain verification is unsafe and can lead to various vulnerabilities. If you turn it off, ensure that the Pages root domain itself does not point to the secondary IP, or add the root domain as a custom domain to a project. Otherwise, any user can add this domain as a custom domain to their project.

If your user base is private or otherwise trusted, you can turn off the verification requirement:

  1. In the upper-right corner, select Admin.
  2. In the left sidebar, select Settings > Preferences.
  3. Expand Pages.
  4. Clear the Require users to prove ownership of custom domains checkbox. This setting is turned on by default.

Let’s Encrypt integration

GitLab Pages’ Let’s Encrypt integration lets users add Let’s Encrypt SSL certificates for GitLab Pages sites served under a custom domain.

To turn it on:

  1. Choose an email address to receive notifications about expiring domains.
  2. In the upper-right corner, select Admin.
  3. In the left sidebar, select Settings > Preferences.
  4. Expand Pages.
  5. Enter the email address for receiving notifications and accept the Terms of Service for Let’s Encrypt.
  6. Select Save changes.

Global settings

The following table explains all configuration settings known to Pages in a Linux package installation. These options can be adjusted in /etc/gitlab/gitlab.rb, and take effect after you reconfigure GitLab.

Most of these settings do not have to be configured manually unless you need more granular control over how the Pages daemon runs and serves content in your environment.

For more information, see GitLab Pages rate limits.

SettingDefaultDescription
pages_external_url2Not applicableThe URL where GitLab Pages is accessible, including protocol (HTTP / HTTPS). If https:// is used, additional configuration is required. For more information, see wildcard domains with TLS support and custom domains with TLS support.
gitlab_pages[]Not applicable
access_controlNot applicableWhether to turn on access control.
api_secret_keyAuto-generatedFull path to file with secret key used to authenticate with the GitLab API.
artifacts_serverNot applicableTurn on viewing job artifacts in GitLab Pages.
artifacts_server_timeoutNot applicableTimeout (in seconds) for a proxied request to the artifacts server.
artifacts_server_urlGitLab external URL + /api/v4API URL to proxy artifact requests to, for example https://gitlab.com/api/v4. When running a separate Pages server, this URL must point to the main GitLab server’s API.
auth_redirect_uriProject’s subdomain of pages_external_url + /authCallback URL for authenticating with GitLab. URL should be subdomain of pages_external_url + /auth, for example https://projects.example.io/auth. When namespace_in_path is enabled, defaults to pages_external_url + /projects/auth, for example https://example.io/projects/auth.
auth_secretAuto-pulled from GitLabSecret key for signing authentication requests. Leave blank to pull automatically from GitLab during OAuth registration.
client_certNot applicableClient certificate used for mutual TLS with the GitLab API.
client_keyNot applicableClient key used for mutual TLS with the GitLab API.
client_ca_certsNot applicableRoot CA certificates used to sign client certificate used for mutual TLS with the GitLab API.
dirNot applicableWorking directory for configuration and secrets files.
enableNot applicableTurn GitLab Pages on or off for the current system.
external_httpNot applicableConfigure Pages to bind to one or more secondary IP addresses, serving HTTP requests. Multiple addresses can be given as an array, along with exact ports, for example ['1.2.3.4', '1.2.3.5:8063']. Sets value for listen_http. If running GitLab Pages behind a reverse proxy with TLS termination, specify listen_proxy instead of external_http.
external_httpsNot applicableConfigure Pages to bind to one or more secondary IP addresses, serving HTTPS requests. Multiple addresses can be given as an array, along with exact ports, for example ['1.2.3.4', '1.2.3.5:8063']. Sets value for listen_https.
custom_domain_modeNot applicableConfigure Pages to turn on custom domains: http or https. When running a separate Pages server, configure this setting on the GitLab server as well. Introduced in GitLab 18.1.
server_shutdown_timeout30sGitLab Pages server shutdown timeout in seconds.
gitlab_client_http_timeout60sGitLab API HTTP client connection timeout in seconds.
gitlab_client_jwt_expiry30sJWT Token expiry time in seconds.
gitlab_cache_expiry600sThe maximum time a domain’s configuration is stored in the cache.
gitlab_cache_refresh60sThe interval at which a domain’s configuration is set to be due to refresh.
gitlab_cache_cleanup60sThe interval at which expired items are removed from the cache.
gitlab_retrieval_timeout30sThe maximum time to wait for a response from the GitLab API per request.
gitlab_retrieval_interval1sThe interval to wait before retrying to resolve a domain’s configuration by using the GitLab API.
gitlab_retrieval_retries3The maximum number of times to retry to resolve a domain’s configuration by using the GitLab API.
gitlab_idAuto-filledThe OAuth application public ID. Leave blank to automatically fill when Pages authenticates with GitLab.
gitlab_secretAuto-filledThe OAuth application secret. Leave blank to automatically fill when Pages authenticates with GitLab.
auth_scopeapiThe OAuth application scope to use for authentication. Must match GitLab Pages OAuth application settings. Leave blank to use api scope by default.
auth_timeout5sGitLab application client timeout for authentication in seconds. A value of 0 means no timeout.
auth_cookie_session_timeout10mAuthentication cookie session timeout in seconds. A value of 0 means the cookie is deleted after the browser session ends.
gitlab_serverGitLab external_urlServer to use for authentication when access control is turned on.
headersNot applicableSpecify any additional HTTP headers that should be sent to the client with each response. Multiple headers can be given as an array, header and value as one string. For example ['my-header: myvalue', 'my-other-header: my-other-value'].
enable_diskNot applicableAllows the GitLab Pages daemon to serve content from disk. Turn off if shared disk storage is not available.
insecure_ciphersNot applicableUse default list of cipher suites, which may contain insecure ones like 3DES and RC4.
internal_gitlab_serverGitLab external_urlInternal GitLab server address used exclusively for API requests. Use if you want to send that traffic over an internal load balancer.
listen_proxyNot applicableThe addresses to listen on for reverse-proxy requests. Pages binds to these addresses’ network sockets and receives incoming requests from them. Sets the value of proxy_pass in $nginx-dir/conf/gitlab-pages.conf.
log_directoryNot applicableAbsolute path to a log directory.
log_formatNot applicableThe log output format: text or json.
log_verboseNot applicableVerbose logging, true/false.
namespace_in_pathfalseTurn the namespace in the URL path on or off to support single-domain sites DNS setup.
propagate_correlation_idfalseSet to true to re-use existing Correlation ID from the incoming request header X-Request-ID if present. If a reverse proxy sets this header, the value is propagated in the request chain.
max_connectionsNot applicableLimit on the number of concurrent connections to the HTTP, HTTPS or proxy listeners.
max_uri_length2048The maximum length of URIs accepted by GitLab Pages. Set to 0 for unlimited length.
metrics_addressNot applicableThe address to listen on for metrics requests.
redirect_httpNot applicableRedirect pages from HTTP to HTTPS, true/false.
redirects_max_config_size65536The maximum size of the _redirects file, in bytes.
redirects_max_path_segments25The maximum number of path segments allowed in _redirects rules URLs.
redirects_max_rule_count1000The maximum number of rules allowed in _redirects.
sentry_dsnNot applicableThe address for sending Sentry crash reporting to.
sentry_enabledNot applicableTurn on reporting and logging with Sentry, true/false.
sentry_environmentNot applicableThe environment for Sentry crash reporting.
status_uriNot applicableThe URL path for a status page, for example, /@status. Configure to turn on the health check endpoint on GitLab Pages.
tls_max_versionNot applicableSpecifies the maximum TLS version (“tls1.2” or “tls1.3”).
tls_min_versionNot applicableSpecifies the minimum TLS version (“tls1.2” or “tls1.3”).
use_http2Not applicableTurn on HTTP2 support.
gitlab_pages['env'][]Not applicable
http_proxyNot applicableConfigure GitLab Pages to use an HTTP proxy to mediate traffic between Pages and GitLab. Sets an environment variable http_proxy when starting the Pages daemon.
gitlab_rails[]Not applicable
pages_domain_verification_cron_workerNot applicableSchedule for verifying custom GitLab Pages domains.
pages_domain_ssl_renewal_cron_workerNot applicableSchedule for obtaining and renewing SSL certificates through Let’s Encrypt for GitLab Pages domains.
pages_domain_removal_cron_workerNot applicableSchedule for removing unverified custom GitLab Pages domains.
pages_pathGITLAB-RAILS/shared/pagesThe directory on disk where pages are stored.
pages_nginx[]Not applicable
enableNot applicableInclude a virtual host server{} block for Pages inside NGINX. Needed for NGINX to proxy traffic back to the Pages daemon. Set to false if the Pages daemon should directly receive all requests, for example, when using custom domains.
FF_CONFIGURABLE_ROOT_DIRNot applicableFeature flag to customize the default folder (turned on by default).
FF_ENABLE_PLACEHOLDERSNot applicableFeature flag for rewrites (turned on by default). For more information, see rewrites.
rate_limit_source_ipNot applicableRate limit per source IP in number of requests per second. Set to 0 to turn off this feature.
rate_limit_source_ip_burstNot applicableRate limit per source IP maximum burst allowed per second.
rate_limit_domainNot applicableRate limit per domain in number of requests per second. Set to 0 to turn off this feature.
rate_limit_domain_burstNot applicableRate limit per domain maximum burst allowed per second.
rate_limit_tls_source_ipNot applicableRate limit per source IP in number of TLS connections per second. Set to 0 to turn off this feature.
rate_limit_tls_source_ip_burstNot applicableRate limit per source IP maximum TLS connections burst allowed per second.
rate_limit_tls_domainNot applicableRate limit per domain in number of TLS connections per second. Set to 0 to turn off this feature.
rate_limit_tls_domain_burstNot applicableRate limit per domain maximum TLS connections burst allowed per second.
rate_limit_subnets_allow_listNot applicableAllow list with the IP ranges (subnets) that should bypass all rate limits. For example, ['1.2.3.4/24', '2001:db8::1/32']. Introduced in GitLab 17.3.
server_read_timeout5sMaximum duration to read the request headers and body. For no timeout, set to 0 or a negative value.
server_read_header_timeout1sMaximum duration to read the request headers. For no timeout, set to 0 or a negative value.
server_write_timeout0Maximum duration to write all files in the response. Larger files require more time. For no timeout, set to 0 or a negative value.
server_keep_alive15sThe Keep-Alive period for network connections accepted by this listener. If 0, Keep-Alive is turned on if supported by the protocol and operating system. If negative, Keep-Alive is turned off.

Access control

GitLab Pages access control can be configured per-project, and allows access to a Pages site to be controlled based on a user’s membership to that project.

Access control works by registering the Pages daemon as an OAuth application with GitLab. Whenever an unauthenticated user requests access to a private Pages site, the Pages daemon redirects the user to GitLab. If authentication is successful, the user is redirected back to Pages with a token, which is persisted in a cookie. The cookies are signed with a secret key, so tampering can be detected.

Each request to view a resource in a private site is authenticated by Pages using that token. For each request it receives, Pages makes a request to the GitLab API to check that the user is authorized to read that site.

Pages access control is turned off by default. To turn it on:

  1. In /etc/gitlab/gitlab.rb, add:

    ruby
    gitlab_pages['access_control'] = true
  2. Save the file and reconfigure GitLab for the changes to take effect.

  3. Users can now configure it in their projects’ settings.

For this setting to be effective with multi-node setups, apply it to all App nodes and Sidekiq nodes.

Using Pages with reduced authentication scope

You can configure the scope the Pages daemon uses to authenticate. By default, it uses the api scope.

For example, this reduces the scope to read_api in /etc/gitlab/gitlab.rb:

ruby
gitlab_pages['auth_scope'] = 'read_api'

The scope to use for authentication must match the GitLab Pages OAuth application settings. Users of pre-existing applications must modify the GitLab Pages OAuth application.

Prerequisites:

To change the scope Pages uses:

  1. In the upper-right corner, select Admin.
  2. In the left sidebar, select Applications.
  3. Expand GitLab Pages.
  4. Clear the api scope’s checkbox and select the desired scope’s checkbox (for example, read_api).
  5. Select Save changes.

Disable public access to all Pages sites

You can enforce access control for all GitLab Pages websites hosted on your GitLab instance. When you turn on this setting, only authenticated users can access Pages websites. All projects lose the Everyone visibility level option and are restricted to project members or everyone with access, depending on the project’s visibility setting.

Use this setting to restrict information published with Pages to the users of your instance only.

Prerequisites:

  • Administrator access to the instance.
  • Access control turned on for the setting to show in the Admin area.

To turn off public access to all Pages sites:

  1. In the upper-right corner, select Admin.
  2. In the left sidebar, select Settings > Preferences.
  3. Expand Pages.
  4. Select the Disable public access to Pages sites checkbox.
  5. Select Save changes.

Disable unique domains by default

By default, all newly created GitLab Pages sites use unique domain URLs (for example, my-project-1a2b3c.example.com), which prevents cookie sharing between different sites under the same namespace.

You can turn off this default behavior so that new Pages sites use path-based URLs (for example, my-namespace.example.com/my-project) instead. However, this approach has the risk of cookie sharing between different sites under the same namespace.

This setting controls the default behavior for new sites only. Users can still override this setting for individual projects.

Prerequisites:

  • You must have administrator access to the instance.

To turn off unique domains by default:

  1. In the upper-right corner, select Admin.
  2. In the left sidebar, select Settings > Preferences.
  3. Expand Pages.
  4. Clear the Enable unique domains by default checkbox.
  5. Select Save changes.

This setting only affects new Pages sites. Existing sites maintain their current unique domain configuration.

Networking and certificates

Configure how the GitLab Pages daemon handles network connections, certificates, and security headers.

Running behind a proxy

You can use GitLab Pages in environments where external internet connectivity is gated by a proxy.

To use a proxy for GitLab Pages:

  1. In /etc/gitlab/gitlab.rb, add:

    ruby
    gitlab_pages['env']['http_proxy'] = 'http://example:8080'
  2. Save the file and reconfigure GitLab for the changes to take effect.

Using a custom Certificate Authority (CA)

When using certificates issued by a custom CA, access control and the online view of HTML job artifacts fail to work if the custom CA is not recognized.

This usually results in this error:

Post /oauth/token: x509: certificate signed by unknown authority

To resolve this:

  • For Linux package installations, install a custom CA.
  • For self-compiled installations, install the custom CA in the system certificate store.

Support mutual TLS when calling the GitLab API

If GitLab is configured to require mutual TLS, you must add client certificates to your GitLab Pages configuration.

Certificates have these requirements:

  • The certificate must specify the hostname or IP address as a Subject Alternative Name.
  • The full certificate chain is required, including the end-user certificate, intermediate certificates, and the root certificate, in that order.

The certificate’s Common Name field is ignored.

Prerequisites:

  • Your instance uses the Linux package installation method.

To configure the certificates in your GitLab Pages server:

  1. On the GitLab Pages nodes, create the /etc/gitlab/ssl directory and copy your key and full certificate chain there:

    shell
    sudo mkdir -p /etc/gitlab/ssl
    sudo chmod 755 /etc/gitlab/ssl
    sudo cp key.pem cert.pem /etc/gitlab/ssl/
    sudo chmod 644 key.pem cert.pem
  2. Edit /etc/gitlab/gitlab.rb:

    ruby
    gitlab_pages['client_cert'] = ['/etc/gitlab/ssl/cert.pem']
    gitlab_pages['client_key'] = ['/etc/gitlab/ssl/key.pem']
  3. If you used a custom CA, copy the root CA certificate to /etc/gitlab/ssl and edit /etc/gitlab/gitlab.rb:

    ruby
    gitlab_pages['client_ca_certs'] = ['/etc/gitlab/ssl/ca.pem']

    File paths for multiple custom Certificate Authorities are separated by commas.

  4. If you have a multi-node GitLab Pages installation, repeat these steps on all nodes.

  5. Save a copy of the full certificate chain files in the /etc/gitlab/trusted-certs directory on all your GitLab nodes.

HTTP Strict Transport Security (HSTS) support

HTTP Strict Transport Security (HSTS) can be turned on through the gitlab_pages['headers'] configuration option. HSTS informs browsers that the website should always be accessed over HTTPS, preventing attackers from forcing unencrypted connections. It can also improve page loading speed by preventing browsers from attempting an unencrypted HTTP connection before being redirected to HTTPS.

ruby
gitlab_pages['headers'] = ['Strict-Transport-Security: max-age=63072000']

Configure listener for reverse proxy requests

To configure the proxy listener of GitLab Pages:

  1. By default the listener is configured to listen for requests on localhost:8090.

    To turn it off, edit /etc/gitlab/gitlab.rb:

    ruby
    gitlab_pages['listen_proxy'] = nil

    To change the port, edit /etc/gitlab/gitlab.rb:

    ruby
    gitlab_pages['listen_proxy'] = "localhost:10080"
  2. Save the file and reconfigure GitLab for the changes to take effect.

Configurable limits

Set limits on GitLab Pages sites, like site size and the number of custom domains, files, and redirect rules. You can also set when parallel deployments expire by default.

Set global maximum size of each GitLab Pages site

  • Tier: Free, Premium, Ultimate
  • Offering: GitLab Self-Managed

Prerequisites:

  • You must have administrator access to the instance.

To set the global maximum pages size for a project: