Merge branch 'nginx-log-format' into 'master'

Make the NGINX access log format configurable

This is useful for experimenting on gitlab.com.

See merge request !436
This commit is contained in:
Marin Jankovski 2015-08-27 16:09:49 +00:00
commit 03511afa1d
8 changed files with 30 additions and 6 deletions

View File

@ -84,3 +84,17 @@ Example log messages:
2014-06-26_13:33:46.52608 ubuntu1204-test sidekiq: 2014-06-26T13:33:46Z 18107 TID-7muoc RepositoryImportWorker JID-57ee926c3655fcfa062338ae INFO: start
```
### Using a custom NGINX log format
By default the NGINX access logs will use the 'combined' NGINX
format, see
http://nginx.org/en/docs/http/ngx_http_log_module.html#log_format .
If you want to use a custom log format string you can specify it
in gitlab.rb.
```
nginx['log_format'] = 'my format string $foo $bar'
ci_nginx['log_format'] = 'my format string $foo $bar'
mattermost_nginx['log_format'] = 'my format string $foo $bar'
```

View File

@ -398,6 +398,7 @@ external_url 'GENERATED_EXTERNAL_URL'
# nginx['log_directory'] = "/var/log/gitlab/nginx"
# nginx['worker_processes'] = 4
# nginx['worker_connections'] = 10240
# nginx['log_format'] = '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent"'
# nginx['sendfile'] = 'on'
# nginx['tcp_nopush'] = 'on'
# nginx['tcp_nodelay'] = 'on'

View File

@ -347,6 +347,7 @@ default['gitlab']['nginx']['dir'] = "/var/opt/gitlab/nginx"
default['gitlab']['nginx']['log_directory'] = "/var/log/gitlab/nginx"
default['gitlab']['nginx']['worker_processes'] = node['cpu']['total'].to_i
default['gitlab']['nginx']['worker_connections'] = 10240
default['gitlab']['nginx']['log_format'] = '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent"' # NGINX 'combined' format
default['gitlab']['nginx']['sendfile'] = 'on'
default['gitlab']['nginx']['tcp_nopush'] = 'on'
default['gitlab']['nginx']['tcp_nodelay'] = 'on'

View File

@ -148,6 +148,10 @@ template gitlab_mattermost_http_conf do
action gitlab_mattermost_enabled ? :create : :delete
end
nginx_vars['gitlab_access_log_format'] = node['gitlab']['nginx']['log_format']
nginx_vars['gitlab_ci_access_log_format'] = node['gitlab']['ci-nginx']['log_format']
nginx_vars['gitlab_mattermost_access_log_format'] = node['gitlab']['mattermost-nginx']['log_format']
template nginx_config do
source "nginx.conf.erb"
owner "root"

View File

@ -16,7 +16,7 @@ server {
server_name <%= @fqdn %>;
server_tokens off;
return 301 https://<%= @fqdn %>:<%= @port %>$request_uri;
access_log <%= @log_directory %>/gitlab_ci_access.log;
access_log <%= @log_directory %>/gitlab_ci_access.log gitlab_ci_access;
error_log <%= @log_directory %>/gitlab_ci_error.log;
}
<% end %>
@ -50,7 +50,7 @@ server {
<% end %>
## Individual nginx logs for this GitLab CI vhost
access_log <%= @log_directory %>/gitlab_ci_access.log;
access_log <%= @log_directory %>/gitlab_ci_access.log gitlab_ci_access;
error_log <%= @log_directory %>/gitlab_ci_error.log;
location / {

View File

@ -49,7 +49,7 @@ server {
server_name <%= @fqdn %>;
server_tokens off; ## Don't show the nginx version number, a security best practice
return 301 https://<%= @fqdn %>:<%= @port %>$request_uri;
access_log <%= @log_directory %>/gitlab_access.log;
access_log <%= @log_directory %>/gitlab_access.log gitlab_access;
error_log <%= @log_directory %>/gitlab_error.log;
}
<% end %>
@ -94,7 +94,7 @@ server {
<% end %>
## Individual nginx logs for this GitLab vhost
access_log <%= @log_directory %>/gitlab_access.log;
access_log <%= @log_directory %>/gitlab_access.log gitlab_access;
error_log <%= @log_directory %>/gitlab_error.log;
location / {

View File

@ -16,7 +16,7 @@ server {
server_name <%= @fqdn %>;
server_tokens off;
return 301 https://<%= @fqdn %>:<%= @port %>$request_uri;
access_log <%= @log_directory %>/gitlab_mattermost_access.log;
access_log <%= @log_directory %>/gitlab_mattermost_access.log gitlab_mattermost_access;
error_log <%= @log_directory %>/gitlab_mattermost_error.log;
}
<% end %>
@ -42,7 +42,7 @@ server {
<% end %>
<% end %>
access_log <%= @log_directory %>/gitlab_mattermost_access.log;
access_log <%= @log_directory %>/gitlab_mattermost_access.log gitlab_mattermost_access;
error_log <%= @log_directory %>/gitlab_mattermost_error.log;
location / {

View File

@ -14,6 +14,10 @@ events {
}
http {
log_format gitlab_access '<%= @gitlab_access_log_format %>';
log_format gitlab_ci_access '<%= @gitlab_ci_access_log_format %>';
log_format gitlab_mattermost_access '<%= @gitlab_mattermost_access_log_format %>';
sendfile <%= @sendfile %>;
tcp_nopush <%= @tcp_nopush %>;
tcp_nodelay <%= @tcp_nodelay %>;