server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; server_name gitlab.wu-boy.com; return 301 https://gitlab.wu-boy.com$request_uri; } # https://gitlab.com/gitlab-org/gitlab-ce/issues/2682 upstream gitlab { server 127.0.0.1:10080 fail_timeout=0; } upstream gitlab-git-http-server { server 127.0.0.1:8181 fail_timeout=0; } # let gitlab deal with the redirection server { listen 0.0.0.0:443 ssl http2; listen [::]:443 ssl http2 ipv6only=on default_server; server_name gitlab.wu-boy.com; server_tokens off; root /opt/gitlab/embedded/service/gitlab-rails/public; # include ssl config include ssl/gitlab.conf; # Increase this if you want to upload larger attachments client_max_body_size 20m; # individual nginx logs for this vhost access_log /var/log/nginx/gitlab_access.log; error_log /var/log/nginx/gitlab_error.log; # Increase this if you want to upload larger attachments client_max_body_size 20m; ## Individual nginx logs for this GitLab vhost access_log /var/log/nginx/gitlab_access.log; error_log /var/log/nginx/gitlab_error.log; location / { ## Serve static files from defined root folder. ## @gitlab is a named location for the upstream fallback, see below. try_files $uri $uri/index.html $uri.html @gitlab; } ## We route uploads through GitLab to prevent XSS and enforce access control. location /uploads/ { ## If you use HTTPS make sure you disable gzip compression ## to be safe against BREACH attack. gzip off; ## https://github.com/gitlabhq/gitlabhq/issues/694 ## Some requests take more than 30 seconds. proxy_read_timeout 300; proxy_connect_timeout 300; proxy_redirect off; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-Ssl on; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Frame-Options SAMEORIGIN; proxy_pass http://gitlab; } ## If a file, which is not found in the root folder is requested, ## then the proxy passes the request to the upsteam (gitlab unicorn). location @gitlab { ## If you use HTTPS make sure you disable gzip compression ## to be safe against BREACH attack. gzip off; ## https://github.com/gitlabhq/gitlabhq/issues/694 ## Some requests take more than 30 seconds. proxy_read_timeout 300; proxy_connect_timeout 300; proxy_redirect off; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-Ssl on; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Frame-Options SAMEORIGIN; proxy_pass http://gitlab; } location ~ [-\/\w\.]+\.git\/ { ## If you use HTTPS make sure you disable gzip compression ## to be safe against BREACH attack. gzip off; ## https://github.com/gitlabhq/gitlabhq/issues/694 ## Some requests take more than 30 seconds. proxy_read_timeout 300; proxy_connect_timeout 300; proxy_redirect off; # Do not buffer Git HTTP responses proxy_buffering off; # The following settings only work with NGINX 1.7.11 or newer # # # Pass chunked request bodies to gitlab-git-http-server as-is # proxy_request_buffering off; # proxy_http_version 1.1; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-Ssl on; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_pass http://gitlab-git-http-server; } error_page 502 /502.html; }