@@ -29,6 +29,15 @@ map $http_upgrade $connection_upgrade_gitlab_ssl {
29
29
'' close;
30
30
}
31
31
32
+ ## Obfuscate access_token and private_token in access log
33
+ map $request_uri $obfuscated_request_uri {
34
+ ~(.+\?)(.*&)?(private_token=|access_token=)[^&]*(&.*|$) $1$2$3****$4;
35
+ default $request_uri;
36
+ }
37
+ log_format main '$remote_addr - $remote_user [$time_local] '
38
+ '"$request_method $obfuscated_request_uri $server_protocol" $status $body_bytes_sent '
39
+ '"$http_referer" "$http_user_agent"';
40
+
32
41
## Redirects all HTTP traffic to the HTTPS host
33
42
server {
34
43
## Either remove "default_server" from the listen line below,
@@ -40,7 +49,7 @@ server {
40
49
server_name _; ## Replace this with something like gitlab.example.com
41
50
server_tokens off; ## Don't show the nginx version number, a security best practice
42
51
return 301 https://$host:{{GITLAB_PORT}}$request_uri;
43
- access_log {{GITLAB_LOG_DIR}}/nginx/gitlab_access.log;
52
+ access_log {{GITLAB_LOG_DIR}}/nginx/gitlab_access.log main ;
44
53
error_log {{GITLAB_LOG_DIR}}/nginx/gitlab_error.log;
45
54
}
46
55
@@ -94,7 +103,7 @@ server {
94
103
ssl_dhparam {{SSL_DHPARAM_PATH}};
95
104
96
105
## Individual nginx logs for this GitLab vhost
97
- access_log {{GITLAB_LOG_DIR}}/nginx/gitlab_access.log;
106
+ access_log {{GITLAB_LOG_DIR}}/nginx/gitlab_access.log main ;
98
107
error_log {{GITLAB_LOG_DIR}}/nginx/gitlab_error.log;
99
108
100
109
location / {
0 commit comments