Skip to content
This repository was archived by the owner on Aug 13, 2024. It is now read-only.

Nginx log postdata #82

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,11 @@ docker-compose.yml::
${MAKO_CMD} --var "rancher_deploy=$(RANCHER_DEPLOY)" \
--var "image_tag=$(IMAGE_TAG)" \
--var "nginx_port=$(NGINX_PORT)" \
--var "nginx_log_level=$(NGINX_LOG_LEVEL)" \
--var "nginx_workers=$(NGINX_WORKERS)" \
--var "wsgi_port=$(WSGI_PORT)" \
--var "tomcat_port=$(TOMCAT_PORT)" \
--var "catalina_opts=$(CATALINA_OPTS)" \
--var "rancher_label=$(RANCHER_LABEL)" \
--var "print_env=$(PRINT_ENV)" docker-compose.yml.in > docker-compose.yml

Expand Down
3 changes: 3 additions & 0 deletions dev.env
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ PRINT_SERVER_HOST=service-print.dev.bgdi.ch
PRINT_TEMP_DIR=/var/local/print
PRINT_LOGLEVEL=10
DEBUG=True
CATALINA_OPTS=2g
NGINX_LOG_LEVEL=warn
NGINX_WORKERS=8
4 changes: 3 additions & 1 deletion docker-compose.yml.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ services:
- ${rancher_label}.env
environment:
NGINX_PORT: ${nginx_port}
NGINX_LOG_LEVEL: ${nginx_log_level}
NGINX_WORKERS: ${nginx_workers}
network_mode: "host"
ports:
- "${nginx_port}:${nginx_port}"
Expand All @@ -30,7 +32,7 @@ services:
- ${rancher_label}.env
environment:
TOMCAT_PORT: ${tomcat_port}
CATALINA_OPTS: -Xmx2g -Xms2g -XX:MaxPermSize=1024m -Dsun.net.inetaddr.ttl=30
CATALINA_OPTS: "-Xmx${catalina_opts} -Xms${catalina_opts} -XX:MaxPermSize=1024m -Dsun.net.inetaddr.ttl=30"
ports:
- "${tomcat_port}:8080"
volumes:
Expand Down
5 changes: 4 additions & 1 deletion int.env
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PRINT_ENV=int
RANCHER_LABEL=int
IMAGE_TAG=r_20190905_0e83024
IMAGE_TAG=5ca057f
NGINX_PORT=8009
TOMCAT_PORT=8011
WSGI_PORT=8010
Expand All @@ -10,3 +10,6 @@ PRINT_SERVER_HOST=service-print.int.bgdi.ch
PRINT_TEMP_DIR=/var/local/print
PRINT_LOGLEVEL=30
DEBUG=True
CATALINA_OPTS=2g
NGINX_LOG_LEVEL=warn
NGINX_WORKERS=8
3 changes: 2 additions & 1 deletion nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
FROM nginx:1.13.3
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get install -y gettext bash
RUN apt-get update && apt-get remove -y nginx && apt-get install -y gettext bash nginx-full
RUN rm /etc/nginx/nginx.conf /etc/nginx/conf.d/default.conf
COPY . /.
COPY log_format.conf /etc/nginx/log_format.conf
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["nginx", "-g", "daemon off;"]
2 changes: 1 addition & 1 deletion nginx/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
set -e

envsubst < nginx.conf.in > /etc/nginx/nginx.conf
envsubst "$(printf '${%s} ' $(/bin/bash -c "compgen -A variable"))" < nginx.conf.in > /etc/nginx/nginx.conf

# Always put this damn shit
exec "$@"
4 changes: 4 additions & 0 deletions nginx/log_format.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# log_format postdata $request_body;
log_format postdata '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$request_body" "$http_user_agent"';
12 changes: 9 additions & 3 deletions nginx/nginx.conf.in
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
user nginx;

# should be equal to the number of process on the host machine
worker_processes 8;
worker_processes ${NGINX_WORKERS};

error_log /dev/stdout debug;
error_log /dev/stdout ${NGINX_LOG_LEVEL};


events {
Expand All @@ -13,7 +13,12 @@ events {

http {
# if we use analytics we may want to turn that off
access_log /dev/stdout;
# log_format postdata $request_body;
# use include because impossible to escape correctly

include log_format.conf;

access_log /dev/stdout combined;
sendfile off;

# this removes the "host_header" related issue
Expand Down Expand Up @@ -86,6 +91,7 @@ http {
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Requested-With' always;

access_log /dev/stdout postdata;
# Do not cache anything
expires off;

Expand Down
5 changes: 4 additions & 1 deletion prod.env
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PRINT_ENV=prod
RANCHER_LABEL=prod
IMAGE_TAG=r_20190905_0e83024
IMAGE_TAG=5ca057f
NGINX_PORT=8009
TOMCAT_PORT=8011
WSGI_PORT=8010
Expand All @@ -10,3 +10,6 @@ PRINT_SERVER_HOST=service-print.prod.bgdi.ch
PRINT_TEMP_DIR=/var/local/print
PRINT_LOGLEVEL=30
DEBUG=False
CATALINA_OPTS=2g
NGINX_LOG_LEVEL=warn
NGINX_WORKERS=8
3 changes: 3 additions & 0 deletions rc_user
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
export $(cat dev.env)
export NGINX_LOG_LEVEL=warn
export NGINX_WORKERS=1
export CATALINA_OPTS=512m