Add JSON logging back for NGINX container.

This configures the NGINX container to log in JSON. It also updates the
K8s config so that we mount all of the key/value pairs available in the
atst-nginx ConfigMap as files in "/etc/nginx/conf.d" inside the
container. This simplifies the config a little.
This commit is contained in:
dandds 2019-11-14 13:25:30 -05:00 committed by tomdds
parent 699176fc91
commit 26c5b5ea7f
2 changed files with 25 additions and 7 deletions

View File

@ -5,8 +5,10 @@ metadata:
name: atst-nginx
namespace: atat
data:
nginx-config: |-
atst.conf: |-
server {
access_log /var/log/nginx/access.log json;
listen ${PORT_PREFIX}342;
server_name ${MAIN_DOMAIN};
root /usr/share/nginx/html;
@ -18,6 +20,8 @@ data:
}
}
server {
access_log /var/log/nginx/access.log json;
listen ${PORT_PREFIX}343;
server_name ${AUTH_DOMAIN};
root /usr/share/nginx/html;
@ -29,6 +33,8 @@ data:
}
}
server {
access_log /var/log/nginx/access.log json;
server_name ${MAIN_DOMAIN};
# access_log /var/log/nginx/access.log json;
listen ${PORT_PREFIX}442 ssl;
@ -58,7 +64,8 @@ data:
}
}
server {
# access_log /var/log/nginx/access.log json;
access_log /var/log/nginx/access.log json;
server_name ${AUTH_DOMAIN};
listen ${PORT_PREFIX}443 ssl;
listen [::]:${PORT_PREFIX}443 ssl ipv6only=on;
@ -88,3 +95,18 @@ data:
uwsgi_param HTTP_X_REQUEST_ID $request_id;
}
}
00json_log.conf: |-
log_format json escape=json
'{'
'"timestamp":"$time_iso8601",'
'"msec":"$msec",'
'"request_id":"$request_id",'
'"remote_addr":"$remote_addr",'
'"remote_user":"$remote_user",'
'"request":"$request",'
'"status":$status,'
'"body_bytes_sent":$body_bytes_sent,'
'"referer":"$http_referer",'
'"user_agent":"$http_user_agent",'
'"http_x_forwarded_for":"$http_x_forwarded_for"'
'}';

View File

@ -62,8 +62,7 @@ spec:
name: auth
volumeMounts:
- name: nginx-config
mountPath: "/etc/nginx/conf.d/atst.conf"
subPath: atst.conf
mountPath: "/etc/nginx/conf.d/"
- name: uwsgi-socket-dir
mountPath: "/var/run/uwsgi"
- name: nginx-htpasswd
@ -90,9 +89,6 @@ spec:
- name: nginx-config
configMap:
name: atst-nginx
items:
- key: nginx-config
path: atst.conf
- name: uwsgi-socket-dir
emptyDir:
medium: Memory