Skip to content

Commit 28d4905

Browse files
committed
Merge pull request #78 from gitlabhq/nginx-version-leak
Remove nginx version number as a security best practice. Hat tip to Remy...
2 parents 6f6e011 + 76ba452 commit 28d4905

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

nginx/gitlab

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ upstream gitlab {
99
server {
1010
listen YOUR_SERVER_IP:80 default_server; # e.g., listen 192.168.1.1:80;
1111
server_name YOUR_SERVER_FQDN; # e.g., server_name source.example.com;
12+
server_tokens off;
1213
root /home/git/gitlab/public;
1314

1415
# individual nginx logs for this gitlab vhost

nginx/gitlab-https

+13-11
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# You need from run openssl to generate the ssl certificate.
99
# $ sudo openssl req -new -x509 -nodes -days 3560 -out gitlab.crt -keyout gitlab.key
1010
# $ sudo chmod o-r gitlab.key
11-
11+
1212
upstream gitlab {
1313
server unix:/home/gitlab/gitlab/tmp/sockets/gitlab.socket;
1414
}
@@ -17,43 +17,45 @@ upstream gitlab {
1717
server {
1818
listen 80;
1919
server_name Domain_NAME;
20+
server_tokens off;
2021
root /nowhere;
2122
rewrite ^ https://gitlab.stardrad.com$request_uri permanent;
2223
}
2324
server {
2425
listen 443;
2526
server_name Domain_NAME;
27+
server_tokens off;
2628
root /home/gitlab/gitlab/public;
27-
29+
2830
ssl on;
2931
ssl_certificate gitlab.crt;
30-
ssl_certificate_key gitlab.key;
31-
ssl_protocols SSLv3 TLSv1 TLSv2;
32-
ssl_ciphers AES:HIGH:!ADH:!MD5;
33-
ssl_prefer_server_ciphers on;
34-
32+
ssl_certificate_key gitlab.key;
33+
ssl_protocols SSLv3 TLSv1 TLSv2;
34+
ssl_ciphers AES:HIGH:!ADH:!MD5;
35+
ssl_prefer_server_ciphers on;
36+
3537
# individual nginx logs for this gitlab vhost
3638
access_log /var/log/nginx/gitlab_access.log;
3739
error_log /var/log/nginx/gitlab_error.log;
38-
40+
3941
location / {
4042
# serve static files from defined root folder;.
4143
# @gitlab is a named location for the upstream fallback, see below
4244
try_files $uri $uri/index.html $uri.html @gitlab;
4345
}
44-
46+
4547
# if a file, which is not found in the root folder is requested,
4648
# then the proxy pass the request to the upsteam (gitlab unicorn)
4749
location @gitlab {
4850
proxy_read_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694
4951
proxy_connect_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694
5052
proxy_redirect off;
51-
53+
5254
proxy_set_header X-Forwarded-Proto https;
5355
proxy_set_header X-Forwarded-Ssl on;
5456
proxy_set_header Host $http_host;
5557
proxy_set_header X-Real-IP $remote_addr;
56-
58+
5759
proxy_pass http://gitlab;
5860
}
5961
}

0 commit comments

Comments
 (0)