فهرست منبع

Merge pull request #77 from bersace/log_format

Parametrize log_format
Jeff Geerling 8 سال پیش
والد
کامیت
769a84ece8
2فایلهای تغییر یافته به همراه5 افزوده شده و 3 حذف شده
  1. 4 0
      defaults/main.yml
  2. 1 3
      templates/nginx.conf.j2

+ 4 - 0
defaults/main.yml

@@ -73,3 +73,7 @@ nginx_upstreams: []
 #     "srv2.example.com weight=3",
 #     "srv2.example.com weight=3",
 #     "srv3.example.com"
 #     "srv3.example.com"
 #   }
 #   }
+nginx_log_format: |
+  '$remote_addr - $remote_user [$time_local] "$request" '
+  '$status $body_bytes_sent "$http_referer" '
+  '"$http_user_agent" "$http_x_forwarded_for"'

+ 1 - 3
templates/nginx.conf.j2

@@ -22,9 +22,7 @@ http {
 
 
     client_max_body_size {{ nginx_client_max_body_size }};
     client_max_body_size {{ nginx_client_max_body_size }};
 
 
-    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
-                      '$status $body_bytes_sent "$http_referer" '
-                      '"$http_user_agent" "$http_x_forwarded_for"';
+    log_format  main  {{ nginx_log_format|indent(23) }};
 
 
     access_log  {{ nginx_access_log }};
     access_log  {{ nginx_access_log }};