Skip to content

Commit 2afea0d

Browse files
committed
Refine nginx config for ssl connections. Implements #67 and #92
1 parent fabeb6a commit 2afea0d

File tree

1 file changed

+30
-22
lines changed

1 file changed

+30
-22
lines changed

web-server/nginx/gitlab-ssl

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,44 @@
11
# GITLAB
2-
# Maintainer: @yin8086
3-
# App Version: 4.1
2+
# Contributors: yin8086, sashkab, orkoden, axilleas
3+
# App Version: 5.4 - 6.0
44

55
# Modified from nginx http version
66
# Modified from http://blog.phusion.nl/2012/04/21/tutorial-setting-up-gitlab-on-debian-6/
77

8-
# You need from run openssl to generate the ssl certificate.
9-
# $ sudo openssl req -new -x509 -nodes -days 3560 -out gitlab.crt -keyout gitlab.key
10-
# $ sudo chmod o-r gitlab.key
8+
# You need to run openssl to generate a self-signed ssl certificate.
9+
# cd /etc/nginx/
10+
# sudo openssl req -new -x509 -nodes -days 3560 -out gitlab.crt -keyout gitlab.key
11+
# sudo chmod o-r gitlab.key
1112

1213
upstream gitlab {
13-
server unix:/home/gitlab/gitlab/tmp/sockets/gitlab.socket;
14+
15+
## Uncomment if you have set up puma/unicorn to listen on a unix socket (recommended).
16+
server unix:/home/git/gitlab/tmp/sockets/gitlab.socket;
17+
18+
## Uncomment if puma/unicorn are configured to listen on a tcp port.
19+
## Check the port number in /home/git/gitlab/config/{puma.rb/unicorn.rb}
20+
# server 127.0.0.1:9292;
1421
}
1522

1623
# This is a normal HTTP host which redirects all traffic to the HTTPS host.
24+
# Replace git.example.com with your FQDN.
1725
server {
18-
listen 80;
19-
server_name Domain_NAME;
26+
listen *:80;
27+
server_name git.example.com;
2028
server_tokens off;
21-
root /nowhere;
22-
rewrite ^ https://gitlab.stardrad.com$request_uri permanent;
29+
root /nowhere; # this doesn't have to be a valid path since we are redirecting, you don't have to change it.
30+
rewrite ^ https://$server_name$request_uri permanent;
2331
}
2432
server {
2533
listen 443;
26-
server_name Domain_NAME;
34+
server_name git.example.com;
2735
server_tokens off;
28-
root /home/gitlab/gitlab/public;
36+
root /home/git/gitlab/public;
2937

3038
ssl on;
31-
ssl_certificate gitlab.crt;
32-
ssl_certificate_key gitlab.key;
33-
ssl_protocols SSLv3 TLSv1 TLSv2;
39+
ssl_certificate /etc/nginx/gitlab.crt;
40+
ssl_certificate_key /etc/nginx/gitlab.key;
41+
ssl_protocols SSLv3 TLSv1 TLSv1.2;
3442
ssl_ciphers AES:HIGH:!ADH:!MD5;
3543
ssl_prefer_server_ciphers on;
3644

@@ -47,15 +55,15 @@ server {
4755
# if a file, which is not found in the root folder is requested,
4856
# then the proxy pass the request to the upsteam (gitlab unicorn)
4957
location @gitlab {
50-
proxy_read_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694
58+
proxy_read_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694
5159
proxy_connect_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694
52-
proxy_redirect off;
60+
proxy_redirect off;
5361

54-
proxy_set_header X-Forwarded-Proto https;
55-
proxy_set_header X-Forwarded-Ssl on;
56-
proxy_set_header Host $http_host;
57-
proxy_set_header X-Real-IP $remote_addr;
62+
proxy_set_header X-Forwarded-Proto https;
63+
proxy_set_header X-Forwarded-Ssl on;
64+
proxy_set_header Host $http_host;
65+
proxy_set_header X-Real-IP $remote_addr;
5866

5967
proxy_pass http://gitlab;
6068
}
61-
}
69+
}

0 commit comments

Comments
 (0)