diff --git a/Dockerfile b/Dockerfile index 671fcf26..b468f9b3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,34 +2,34 @@ FROM ghcr.io/linuxserver/baseimage-alpine:3.13 # install packages RUN \ - echo "**** install build packages ****" && \ - apk add --no-cache \ - apache2-utils \ - git \ - libressl3.1-libssl \ - logrotate \ - nano \ - nginx \ - openssl \ - php7 \ - php7-fileinfo \ - php7-fpm \ - php7-json \ - php7-mbstring \ - php7-openssl \ - php7-session \ - php7-simplexml \ - php7-xml \ - php7-xmlwriter \ - php7-zlib && \ - echo "**** configure nginx ****" && \ - echo 'fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;' >> \ - /etc/nginx/fastcgi_params && \ - rm -f /etc/nginx/conf.d/default.conf && \ - echo "**** fix logrotate ****" && \ - sed -i "s#/var/log/messages {}.*# #g" /etc/logrotate.conf && \ - sed -i 's#/usr/sbin/logrotate /etc/logrotate.conf#/usr/sbin/logrotate /etc/logrotate.conf -s /config/log/logrotate.status#g' \ - /etc/periodic/daily/logrotate + echo "**** install build packages ****" && \ + apk add --no-cache \ + apache2-utils \ + git \ + libressl3.1-libssl \ + logrotate \ + nano \ + nginx \ + openssl \ + php7 \ + php7-fileinfo \ + php7-fpm \ + php7-json \ + php7-mbstring \ + php7-openssl \ + php7-session \ + php7-simplexml \ + php7-xml \ + php7-xmlwriter \ + php7-zlib && \ + echo "**** configure nginx ****" && \ + echo 'fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;' >> \ + /etc/nginx/fastcgi_params && \ + rm -f /etc/nginx/http.d/default.conf && \ + echo "**** fix logrotate ****" && \ + sed -i "s#/var/log/messages {}.*# #g" /etc/logrotate.conf && \ + sed -i 's#/usr/sbin/logrotate /etc/logrotate.conf#/usr/sbin/logrotate /etc/logrotate.conf -s /config/log/logrotate.status#g' \ + /etc/periodic/daily/logrotate # add local files COPY root/ / diff --git a/Dockerfile.aarch64 b/Dockerfile.aarch64 index e40a14cf..73825e67 100644 --- a/Dockerfile.aarch64 +++ b/Dockerfile.aarch64 @@ -2,34 +2,34 @@ FROM ghcr.io/linuxserver/baseimage-alpine:arm64v8-3.13 # install packages RUN \ - echo "**** install build packages ****" && \ - apk add --no-cache \ - apache2-utils \ - git \ - libressl3.1-libssl \ - logrotate \ - nano \ - nginx \ - openssl \ - php7 \ - php7-fileinfo \ - php7-fpm \ - php7-json \ - php7-mbstring \ - php7-openssl \ - php7-session \ - php7-simplexml \ - php7-xml \ - php7-xmlwriter \ - php7-zlib && \ - echo "**** configure nginx ****" && \ - echo 'fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;' >> \ - /etc/nginx/fastcgi_params && \ - rm -f /etc/nginx/conf.d/default.conf && \ - echo "**** fix logrotate ****" && \ - sed -i "s#/var/log/messages {}.*# #g" /etc/logrotate.conf && \ - sed -i 's#/usr/sbin/logrotate /etc/logrotate.conf#/usr/sbin/logrotate /etc/logrotate.conf -s /config/log/logrotate.status#g' \ - /etc/periodic/daily/logrotate + echo "**** install build packages ****" && \ + apk add --no-cache \ + apache2-utils \ + git \ + libressl3.1-libssl \ + logrotate \ + nano \ + nginx \ + openssl \ + php7 \ + php7-fileinfo \ + php7-fpm \ + php7-json \ + php7-mbstring \ + php7-openssl \ + php7-session \ + php7-simplexml \ + php7-xml \ + php7-xmlwriter \ + php7-zlib && \ + echo "**** configure nginx ****" && \ + echo 'fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;' >> \ + /etc/nginx/fastcgi_params && \ + rm -f /etc/nginx/http.d/default.conf && \ + echo "**** fix logrotate ****" && \ + sed -i "s#/var/log/messages {}.*# #g" /etc/logrotate.conf && \ + sed -i 's#/usr/sbin/logrotate /etc/logrotate.conf#/usr/sbin/logrotate /etc/logrotate.conf -s /config/log/logrotate.status#g' \ + /etc/periodic/daily/logrotate # add local files COPY root/ / diff --git a/Dockerfile.armhf b/Dockerfile.armhf index df872dd1..fd13e73e 100644 --- a/Dockerfile.armhf +++ b/Dockerfile.armhf @@ -2,34 +2,34 @@ FROM ghcr.io/linuxserver/baseimage-alpine:arm32v7-3.13 # install packages RUN \ - echo "**** install build packages ****" && \ - apk add --no-cache \ - apache2-utils \ - git \ - libressl3.1-libssl \ - logrotate \ - nano \ - nginx \ - openssl \ - php7 \ - php7-fileinfo \ - php7-fpm \ - php7-json \ - php7-mbstring \ - php7-openssl \ - php7-session \ - php7-simplexml \ - php7-xml \ - php7-xmlwriter \ - php7-zlib && \ - echo "**** configure nginx ****" && \ - echo 'fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;' >> \ - /etc/nginx/fastcgi_params && \ - rm -f /etc/nginx/conf.d/default.conf && \ - echo "**** fix logrotate ****" && \ - sed -i "s#/var/log/messages {}.*# #g" /etc/logrotate.conf && \ - sed -i 's#/usr/sbin/logrotate /etc/logrotate.conf#/usr/sbin/logrotate /etc/logrotate.conf -s /config/log/logrotate.status#g' \ - /etc/periodic/daily/logrotate + echo "**** install build packages ****" && \ + apk add --no-cache \ + apache2-utils \ + git \ + libressl3.1-libssl \ + logrotate \ + nano \ + nginx \ + openssl \ + php7 \ + php7-fileinfo \ + php7-fpm \ + php7-json \ + php7-mbstring \ + php7-openssl \ + php7-session \ + php7-simplexml \ + php7-xml \ + php7-xmlwriter \ + php7-zlib && \ + echo "**** configure nginx ****" && \ + echo 'fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;' >> \ + /etc/nginx/fastcgi_params && \ + rm -f /etc/nginx/http.d/default.conf && \ + echo "**** fix logrotate ****" && \ + sed -i "s#/var/log/messages {}.*# #g" /etc/logrotate.conf && \ + sed -i 's#/usr/sbin/logrotate /etc/logrotate.conf#/usr/sbin/logrotate /etc/logrotate.conf -s /config/log/logrotate.status#g' \ + /etc/periodic/daily/logrotate # add local files COPY root/ / diff --git a/root/defaults/default b/root/defaults/default index 9d44f07d..cdf2fc11 100644 --- a/root/defaults/default +++ b/root/defaults/default @@ -19,12 +19,8 @@ server { location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; - # With php5-cgi alone: fastcgi_pass 127.0.0.1:9000; - # With php5-fpm: - #fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include /etc/nginx/fastcgi_params; - } } diff --git a/root/defaults/nginx.conf b/root/defaults/nginx.conf index 0068a680..61346711 100644 --- a/root/defaults/nginx.conf +++ b/root/defaults/nginx.conf @@ -1,4 +1,4 @@ -## Version 2018/08/16 - Changelog: https://github.com/linuxserver/docker-baseimage-alpine-nginx/commits/master/root/defaults/nginx.conf +## Version 2021/06/15 - Changelog: https://github.com/linuxserver/docker-baseimage-alpine-nginx/commits/master/root/defaults/nginx.conf user abc; worker_processes 4; @@ -72,31 +72,9 @@ http { ## # Virtual Host Configs ## - include /etc/nginx/conf.d/*.conf; + include /etc/nginx/http.d/*.conf; include /config/nginx/site-confs/*; } - -#mail { -# # See sample authentication script at: -# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript -# -# # auth_http localhost/auth.php; -# # pop3_capabilities "TOP" "USER"; -# # imap_capabilities "IMAP4rev1" "UIDPLUS"; -# -# server { -# listen localhost:110; -# protocol pop3; -# proxy on; -# } -# -# server { -# listen localhost:143; -# protocol imap; -# proxy on; -# } -#} daemon off; - diff --git a/root/etc/cont-init.d/20-config b/root/etc/cont-init.d/20-config index c9137f30..88542b97 100644 --- a/root/etc/cont-init.d/20-config +++ b/root/etc/cont-init.d/20-config @@ -2,22 +2,22 @@ # make our folders mkdir -p \ - /config/{nginx/site-confs,www,log/nginx,keys,log/php,php} \ - /run \ - /var/lib/nginx/tmp/client_body \ - /var/tmp/nginx + /config/{nginx/site-confs,www,log/nginx,keys,log/php,php} \ + /run \ + /var/lib/nginx/tmp/client_body \ + /var/tmp/nginx # copy config files [[ ! -f /config/nginx/nginx.conf ]] && \ - cp /defaults/nginx.conf /config/nginx/nginx.conf + cp /defaults/nginx.conf /config/nginx/nginx.conf [[ ! -f /config/nginx/site-confs/default ]] && \ - cp /defaults/default /config/nginx/site-confs/default + cp /defaults/default /config/nginx/site-confs/default [[ $(find /config/www -type f | wc -l) -eq 0 ]] && \ - cp /defaults/index.html /config/www/index.html + cp /defaults/index.html /config/www/index.html # create local php.ini if it doesn't exist, set local timezone [[ ! -f /config/php/php-local.ini ]] && \ - printf "; Edit this file to override php.ini directives and restart the container\\n\\ndate.timezone = %s\\n" "$TZ" > /config/php/php-local.ini + printf "; Edit this file to override php.ini directives and restart the container\\n\\ndate.timezone = %s\\n" "$TZ" > /config/php/php-local.ini # copy user php-local.ini to image cp /config/php/php-local.ini /etc/php7/conf.d/php-local.ini #fix php-fpm log location @@ -27,15 +27,20 @@ sed -i "s#user = nobody.*#user = abc#g" /etc/php7/php-fpm.d/www.conf sed -i "s#group = nobody.*#group = abc#g" /etc/php7/php-fpm.d/www.conf # create override for www.conf if it doesn't exist [[ ! -f /config/php/www2.conf ]] && \ - printf "; Edit this file to override www.conf and php-fpm.conf directives and restart the container\\n\\n; Pool name\\n[www]\\n\\n" > /config/php/www2.conf + printf "; Edit this file to override www.conf and php-fpm.conf directives and restart the container\\n\\n; Pool name\\n[www]\\n\\n" > /config/php/www2.conf # copy user www2.conf to image cp /config/php/www2.conf /etc/php7/php-fpm.d/www2.conf +# backwards compatibility for alpine >=3.14 +if [ ! -e /etc/nginx/conf.d ]; then + ln -s /etc/nginx/http.d /etc/nginx/conf.d +fi + # permissions chown -R abc:abc \ - /config \ - /var/lib/nginx \ - /var/tmp/nginx + /config \ + /var/lib/nginx \ + /var/tmp/nginx chmod -R g+w \ - /config/{nginx,www} + /config/{nginx,www} chmod -R 644 /etc/logrotate.d diff --git a/root/etc/cont-init.d/30-keygen b/root/etc/cont-init.d/30-keygen index 65125ca8..ceef02d0 100644 --- a/root/etc/cont-init.d/30-keygen +++ b/root/etc/cont-init.d/30-keygen @@ -1,10 +1,8 @@ #!/usr/bin/with-contenv bash SUBJECT="/C=US/ST=CA/L=Carlsbad/O=Linuxserver.io/OU=LSIO Server/CN=*" if [[ -f /config/keys/cert.key && -f /config/keys/cert.crt ]]; then -echo "using keys found in /config/keys" + echo "using keys found in /config/keys" else -echo "generating self-signed keys in /config/keys, you can replace these with your own keys if required" -openssl req -new -x509 -days 3650 -nodes -out /config/keys/cert.crt -keyout /config/keys/cert.key -subj "$SUBJECT" + echo "generating self-signed keys in /config/keys, you can replace these with your own keys if required" + openssl req -new -x509 -days 3650 -nodes -out /config/keys/cert.crt -keyout /config/keys/cert.key -subj "$SUBJECT" fi - - diff --git a/root/etc/services.d/nginx/run b/root/etc/services.d/nginx/run index be8943bc..d189b09d 100644 --- a/root/etc/services.d/nginx/run +++ b/root/etc/services.d/nginx/run @@ -1,15 +1,15 @@ #!/usr/bin/with-contenv bash if pgrep -f "[n]ginx:" > /dev/null; then - echo "Zombie nginx processes detected, sending SIGTERM" - pkill -ef [n]ginx: - sleep 1 + echo "Zombie nginx processes detected, sending SIGTERM" + pkill -ef [n]ginx: + sleep 1 fi if pgrep -f "[n]ginx:" > /dev/null; then - echo "Zombie nginx processes still active, sending SIGKILL" - pkill -9 -ef [n]ginx: - sleep 1 + echo "Zombie nginx processes still active, sending SIGKILL" + pkill -9 -ef [n]ginx: + sleep 1 fi exec /usr/sbin/nginx -c /config/nginx/nginx.conf