|
| 1 | +## GitLab |
| 2 | +## |
| 3 | +## Lines starting with two hashes (##) are comments with information. |
| 4 | +## Lines starting with one hash (#) are configuration parameters that can be uncommented. |
| 5 | +## |
| 6 | +################################## |
| 7 | +## CONTRIBUTING ## |
| 8 | +################################## |
| 9 | +## |
| 10 | +## If you change this file in a Merge Request, please also create |
| 11 | +## a Merge Request on https://gitlab.com/gitlab-org/omnibus-gitlab/merge_requests |
| 12 | +## |
| 13 | +################################### |
| 14 | +## configuration ## |
| 15 | +################################### |
| 16 | +## |
| 17 | +## See installation.md#using-https for additional HTTPS configuration details. |
| 18 | + |
| 19 | +upstream gitlab-workhorse { |
| 20 | + server localhost:8181 fail_timeout=0; |
| 21 | +} |
| 22 | + |
| 23 | +map $http_upgrade $connection_upgrade_gitlab { |
| 24 | + default upgrade; |
| 25 | + '' close; |
| 26 | +} |
| 27 | + |
| 28 | +## Obfuscate access_token and private_token in access log |
| 29 | +map $request_uri $obfuscated_request_uri { |
| 30 | + ~(.+\?)(.*&)?(private_token=|access_token=)[^&]*(&.*|$) $1$2$3****$4; |
| 31 | + default $request_uri; |
| 32 | +} |
| 33 | +log_format gitlab_access '$remote_addr - $remote_user [$time_local] ' |
| 34 | + '"$request_method $obfuscated_request_uri $server_protocol" $status $body_bytes_sent ' |
| 35 | + '"$http_referer" "$http_user_agent"'; |
| 36 | + |
| 37 | +## Normal HTTP host |
| 38 | +server { |
| 39 | + ## Either remove "default_server" from the listen line below, |
| 40 | + ## or delete the /etc/nginx/sites-enabled/default file. This will cause gitlab |
| 41 | + ## to be served if you visit any address that your server responds to, eg. |
| 42 | + ## the ip address of the server (http://x.x.x.x/)n 0.0.0.0:80 default_server; |
| 43 | + listen 0.0.0.0:80 default_server; |
| 44 | + listen [::]:80 default_server; |
| 45 | + server_name {{GITLAB_HOST}}; ## Replace this with something like gitlab.example.com |
| 46 | + server_tokens off; ## Don't show the nginx version number, a security best practice |
| 47 | + |
| 48 | + ## See app/controllers/application_controller.rb for headers set |
| 49 | + |
| 50 | + ## Real IP Module Config |
| 51 | + ## http://nginx.org/en/docs/http/ngx_http_realip_module.html |
| 52 | + real_ip_header X-Real-IP; ## X-Real-IP or X-Forwarded-For or proxy_protocol |
| 53 | + real_ip_recursive {{NGINX_REAL_IP_RECURSIVE}}; ## If you enable 'on' |
| 54 | + ## If you have a trusted IP address, uncomment it and set it |
| 55 | + set_real_ip_from {{NGINX_REAL_IP_TRUSTED_ADDRESSES}}; ## Replace this with something like 192.168.1.0/24 |
| 56 | + |
| 57 | + add_header X-Accel-Buffering {{NGINX_ACCEL_BUFFERING}}; |
| 58 | + add_header Strict-Transport-Security "max-age={{NGINX_HSTS_MAXAGE}};"; |
| 59 | + |
| 60 | + ## Individual nginx logs for this GitLab vhost |
| 61 | + access_log {{GITLAB_LOG_DIR}}/nginx/gitlab_access.log gitlab_access; |
| 62 | + error_log {{GITLAB_LOG_DIR}}/nginx/gitlab_error.log; |
| 63 | + |
| 64 | + location / { |
| 65 | + client_max_body_size 0; |
| 66 | + gzip off; |
| 67 | + |
| 68 | + ## https://github.com/gitlabhq/gitlabhq/issues/694 |
| 69 | + ## Some requests take more than 30 seconds. |
| 70 | + proxy_read_timeout 300; |
| 71 | + proxy_connect_timeout 300; |
| 72 | + proxy_redirect off; |
| 73 | + proxy_buffering {{NGINX_PROXY_BUFFERING}}; |
| 74 | + |
| 75 | + proxy_http_version 1.1; |
| 76 | + |
| 77 | + proxy_set_header Host $http_host; |
| 78 | + proxy_set_header X-Real-IP $remote_addr; |
| 79 | + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| 80 | + proxy_set_header X-Forwarded-Proto {{NGINX_X_FORWARDED_PROTO}}; |
| 81 | + proxy_set_header Upgrade $http_upgrade; |
| 82 | + proxy_set_header Connection $connection_upgrade_gitlab; |
| 83 | + |
| 84 | + proxy_pass http://gitlab-workhorse; |
| 85 | + } |
| 86 | + |
| 87 | + error_page 404 /404.html; |
| 88 | + error_page 422 /422.html; |
| 89 | + error_page 500 /500.html; |
| 90 | + error_page 502 /502.html; |
| 91 | + error_page 503 /503.html; |
| 92 | + location /assets/ { |
| 93 | + alias {{GITLAB_INSTALL_DIR}}/public/assets/; |
| 94 | + expires max; |
| 95 | + add_header Cache-Control public; |
| 96 | + } |
| 97 | + location ~ ^/(404|422|500|502|503)\.html$ { |
| 98 | + root {{GITLAB_INSTALL_DIR}}/public; |
| 99 | + internal; |
| 100 | + } |
| 101 | + |
| 102 | + {{NGINX_CUSTOM_GITLAB_SERVER_CONFIG}} |
| 103 | +} |
0 commit comments