From 0309a90336b91af271ee2815c7f8ed1b2d681f57 Mon Sep 17 00:00:00 2001 From: Vlad Marchenko Date: Mon, 21 Sep 2015 15:40:39 -0500 Subject: [PATCH] Added `NGINX_ENABLED` env variable allowing to disable internal nginx server. --- README.md | 1 + assets/config/redmine/unicorn.rb | 2 +- assets/setup/install.sh | 20 ++--- entrypoint.sh | 127 ++++++++++++++++++------------- 4 files changed, 86 insertions(+), 64 deletions(-) diff --git a/README.md b/README.md index 66fda1de3..c0773e493 100644 --- a/README.md +++ b/README.md @@ -573,6 +573,7 @@ Below is the complete list of parameters that can be set using environment varia - **DB_USER**: The database user. Defaults to `root` - **DB_PASS**: The database password. Defaults to no password - **DB_POOL**: The database connection pool count. Defaults to `5`. +- **NGINX_ENABLED**: Start internal nginx server. Set to `false` and publish 8080 port to use external proxy server. Defaults to `true`. - **NGINX_WORKERS**: The number of nginx workers to start. Defaults to `1`. - **NGINX_MAX_UPLOAD_SIZE**: Maximum acceptable upload size. Defaults to `20m`. - **NGINX_X_FORWARDED_PROTO**: Advanced configuration option for the `proxy_set_header X-Forwarded-Proto` setting in the redmine nginx vHost configuration. Defaults to `https` when `REDMINE_HTTPS` is `true`, else defaults to `$scheme`. diff --git a/assets/config/redmine/unicorn.rb b/assets/config/redmine/unicorn.rb index 11d7f46b5..eb319c85b 100644 --- a/assets/config/redmine/unicorn.rb +++ b/assets/config/redmine/unicorn.rb @@ -29,7 +29,7 @@ # listen on both a Unix domain socket and a TCP port, # we use a shorter backlog for quicker failover when busy listen "{{REDMINE_INSTALL_DIR}}/tmp/sockets/redmine.socket", :backlog => 64 -listen "127.0.0.1:8080", :tcp_nopush => true +listen {{UNICORN_LISTEN}}, :tcp_nopush => true # nuke workers after 30 seconds instead of 60 seconds (the default) timeout {{UNICORN_TIMEOUT}} diff --git a/assets/setup/install.sh b/assets/setup/install.sh index 92c59589e..1df87f110 100755 --- a/assets/setup/install.sh +++ b/assets/setup/install.sh @@ -88,19 +88,21 @@ ln -sf ${REDMINE_LOG_DIR}/redmine log chmod -R u+rwX files tmp chown -R ${REDMINE_USER}:${REDMINE_USER} ${REDMINE_INSTALL_DIR} -# disable default nginx configuration -rm -f /etc/nginx/sites-enabled/default +if [[ ${NGINX_ENABLED} == true ]]; then + # disable default nginx configuration + rm -f /etc/nginx/sites-enabled/default -# run nginx as ${REDMINE_USER} user -sed 's/user www-data/user '"${REDMINE_USER}"'/' -i /etc/nginx/nginx.conf + # run nginx as ${REDMINE_USER} user + sed 's/user www-data/user '"${REDMINE_USER}"'/' -i /etc/nginx/nginx.conf + + # move nginx logs to ${REDMINE_LOG_DIR}/nginx + sed 's|access_log /var/log/nginx/access.log;|access_log '"${REDMINE_LOG_DIR}"'/nginx/access.log;|' -i /etc/nginx/nginx.conf + sed 's|error_log /var/log/nginx/error.log;|error_log '"${REDMINE_LOG_DIR}"'/nginx/error.log;|' -i /etc/nginx/nginx.conf +fi # move supervisord.log file to ${REDMINE_LOG_DIR}/supervisor/ sed 's|^logfile=.*|logfile='"${REDMINE_LOG_DIR}"'/supervisor/supervisord.log ;|' -i /etc/supervisor/supervisord.conf -# move nginx logs to ${REDMINE_LOG_DIR}/nginx -sed 's|access_log /var/log/nginx/access.log;|access_log '"${REDMINE_LOG_DIR}"'/nginx/access.log;|' -i /etc/nginx/nginx.conf -sed 's|error_log /var/log/nginx/error.log;|error_log '"${REDMINE_LOG_DIR}"'/nginx/error.log;|' -i /etc/nginx/nginx.conf - # setup log rotation for redmine application logs cat > /etc/logrotate.d/redmine < /etc/supervisor/conf.d/nginx.conf < /etc/supervisor/conf.d/nginx.conf <