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

Commit

Permalink
nginx log postdata + config for environments
Browse files Browse the repository at this point in the history
  • Loading branch information
procrastinatio committed Apr 10, 2018
1 parent 3eb9d80 commit 2a42ac7
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 8 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,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=debug
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
CATALINA_OPTS: "-Xmx${catalina_opts} -Xms${catalina_opts} -XX:MaxPermSize=1024m"
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=f19ad65
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
2 changes: 1 addition & 1 deletion nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM nginx:1.13.3
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 . /.
ENTRYPOINT ["/docker-entrypoint.sh"]
Expand Down
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 "$@"
11 changes: 8 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,11 @@ events {

http {
# if we use analytics we may want to turn that off
access_log /dev/stdout;
# log_format postdata $request_body;
log_format postdata '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" "$request_body"';
access_log /dev/stdout combined;
sendfile off;

# this removes the "host_header" related issue
Expand Down Expand Up @@ -86,6 +90,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=f19ad65
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

0 comments on commit 2a42ac7

Please sign in to comment.