1
0

gitlab-http.conf 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. # This file is managed by gitlab-ctl. Manual changes will be
  2. # erased! To change the contents below, edit /etc/gitlab/gitlab.rb
  3. # and run `sudo gitlab-ctl reconfigure`.
  4. ## GitLab
  5. ## Modified from https://gitlab.com/gitlab-org/gitlab-foss/blob/master/lib/support/nginx/gitlab-ssl & https://gitlab.com/gitlab-org/gitlab-foss/blob/master/lib/support/nginx/gitlab
  6. ##
  7. ## Lines starting with two hashes (##) are comments with information.
  8. ## Lines starting with one hash (#) are configuration parameters that can be uncommented.
  9. ##
  10. ##################################
  11. ## CHUNKED TRANSFER ##
  12. ##################################
  13. ##
  14. ## It is a known issue that Git-over-HTTP requires chunked transfer encoding [0]
  15. ## which is not supported by Nginx < 1.3.9 [1]. As a result, pushing a large object
  16. ## with Git (i.e. a single large file) can lead to a 411 error. In theory you can get
  17. ## around this by tweaking this configuration file and either:
  18. ## - installing an old version of Nginx with the chunkin module [2] compiled in, or
  19. ## - using a newer version of Nginx.
  20. ##
  21. ## At the time of writing we do not know if either of these theoretical solutions works.
  22. ## As a workaround users can use Git over SSH to push large files.
  23. ##
  24. ## [0] https://git.kernel.org/cgit/git/git.git/tree/Documentation/technical/http-protocol.txt#n99
  25. ## [1] https://github.com/agentzh/chunkin-nginx-module#status
  26. ## [2] https://github.com/agentzh/chunkin-nginx-module
  27. ##
  28. ###################################
  29. ## configuration ##
  30. ###################################
  31. server { ## HTTPS server
  32. listen *:80;
  33. server_name docker.gitlab.com;
  34. server_tokens off; ## Don't show the nginx version number, a security best practice
  35. ## Increase this if you want to upload large attachments
  36. ## Or if you want to accept large git objects over http
  37. client_max_body_size 0;
  38. ## Real IP Module Config
  39. ## http://nginx.org/en/docs/http/ngx_http_realip_module.html
  40. ## HSTS Config
  41. ## https://www.nginx.com/blog/http-strict-transport-security-hsts-and-nginx/
  42. add_header Strict-Transport-Security "max-age=63072000";
  43. # Rails sets a default policy of strict-origin-when-cross-origin, so
  44. # hide that and just send the one we've configured for nginx
  45. proxy_hide_header Referrer-Policy;
  46. add_header Referrer-Policy strict-origin-when-cross-origin;
  47. ## Individual nginx logs for this GitLab vhost
  48. access_log /var/log/gitlab/nginx/gitlab_access.log gitlab_access;
  49. error_log /var/log/gitlab/nginx/gitlab_error.log error;
  50. if ($http_host = "") {
  51. set $http_host_with_default "docker.gitlab.com";
  52. }
  53. if ($http_host != "") {
  54. set $http_host_with_default $http_host;
  55. }
  56. gzip on;
  57. gzip_static on;
  58. gzip_comp_level 2;
  59. gzip_http_version 1.1;
  60. gzip_vary on;
  61. gzip_disable "msie6";
  62. gzip_min_length 250;
  63. gzip_proxied no-cache no-store private expired auth;
  64. gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript application/json;
  65. ## https://github.com/gitlabhq/gitlabhq/issues/694
  66. ## Some requests take more than 30 seconds.
  67. proxy_read_timeout 3600;
  68. proxy_connect_timeout 300;
  69. proxy_redirect off;
  70. proxy_http_version 1.1;
  71. proxy_set_header Host $http_host_with_default;
  72. proxy_set_header X-Real-IP $remote_addr;
  73. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  74. proxy_set_header Upgrade $http_upgrade;
  75. proxy_set_header Connection $connection_upgrade;
  76. proxy_set_header X-Forwarded-Proto http;
  77. location ~ (/api/v\d/jobs/\d+/artifacts$|/import/gitlab_project$|\.git/git-receive-pack$|\.git/ssh-receive-pack$|\.git/ssh-upload-pack$|\.git/gitlab-lfs/objects|\.git/info/lfs/objects/batch$) {
  78. proxy_cache off;
  79. proxy_pass http://gitlab-workhorse;
  80. proxy_request_buffering off;
  81. }
  82. location ~ ^/api/v\d {
  83. proxy_cache off;
  84. proxy_pass http://gitlab-workhorse;
  85. proxy_intercept_errors off;
  86. }
  87. location = /-/kubernetes-agent/ {
  88. proxy_pass http://localhost:8150/;
  89. proxy_intercept_errors off;
  90. }
  91. location /-/kubernetes-agent/k8s-proxy/ {
  92. proxy_pass http://localhost:8154/;
  93. proxy_buffering off;
  94. proxy_intercept_errors off;
  95. }
  96. # health checks configuration
  97. include /var/opt/gitlab/nginx/conf/gitlab-health.conf;
  98. location / {
  99. proxy_cache off;
  100. proxy_pass http://gitlab-workhorse;
  101. }
  102. location /assets {
  103. add_header X-Content-Type-Options nosniff;
  104. proxy_cache gitlab;
  105. proxy_pass http://gitlab-workhorse;
  106. }
  107. error_page 404 /404.html;
  108. error_page 500 /500.html;
  109. error_page 502 /502.html;
  110. location ~ ^/(404|500|502)(-custom)?\.html$ {
  111. root /opt/gitlab/embedded/service/gitlab-rails/public;
  112. internal;
  113. }
  114. } ## end HTTPS server