#!/usr/bin/with-contenv bash touch /config/log/nginx/access.log touch /config/log/nginx/error.log # Download dhparams if necessary if [ ! -f /config/nginx/dhparams.pem ]; then curl -o /config/nginx/dhparams.pem -L "https://ssl-config.mozilla.org/ffdhe4096.txt" fi # Set resolver touch /config/nginx/resolver.conf if ! grep -q 'resolver' /config/nginx/resolver.conf; then RESOLVERRAW=$(awk 'BEGIN{ORS=" "} $1=="nameserver" {print $2}' /etc/resolv.conf) for i in ${RESOLVERRAW}; do if [[ "$(awk -F ':' '{print NF-1}' <<< "${i}")" -le 2 ]]; then RESOLVER="${RESOLVER} ${i}" fi done if [[ -z "${RESOLVER}" ]]; then RESOLVER="127.0.0.11" fi echo "Setting resolver to ${RESOLVER}" RESOLVEROUTPUT="# This file is auto-generated only on first start, based on the container's /etc/resolv.conf file. Feel free to modify it as you wish.\n\nresolver ${RESOLVER} valid=30s;" echo -e "${RESOLVEROUTPUT}" > /config/nginx/resolver.conf fi # Set worker_processes touch /config/nginx/worker_processes.conf if ! grep -q 'worker_processes' /config/nginx/worker_processes.conf; then WORKER_PROCESSES=$(nproc) echo "Setting worker_processes to ${WORKER_PROCESSES}" echo -e "# This file is auto-generated only on first start, based on the cpu cores detected. Feel free to change it to any other number or to auto to let nginx handle it automatically.\n\nworker_processes ${WORKER_PROCESSES};" >/config/nginx/worker_processes.conf fi