diff --git a/Dockerfile b/Dockerfile index 2066ac8..9413c5f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -30,6 +30,8 @@ ENV php_version=${php_version} \ DOCUMENT_ROOT=/var/www/html \ APACHE_EXTRA_CONF="" \ APACHE_EXTRA_CONF_DIR="" \ + SYSLOG_SERVER_IP=localhost \ + SYSLOG_SERVER_PORT=514 \ composer_version=${composer_version} # Add our setup scripts and run the base one @@ -43,6 +45,8 @@ ADD apache2_conf /etc/apache2 ADD php_conf /etc/php/${php_version}/mods-available ADD phpfpm_conf /etc/php/${php_version}/fpm/pool.d ADD supervisor_conf/supervisord.conf /etc/supervisor/ +ADD supervisor_conf/syslog.conf /etc/supervisor/conf.d/ +ADD rsyslog_conf/rsyslog.conf /etc/rsyslog.conf COPY --from=supervisord /go/bin/supervisord /usr/bin/ # Enable our specific configuration diff --git a/README.md b/README.md index 1aa005a..db80eb3 100644 --- a/README.md +++ b/README.md @@ -26,20 +26,20 @@ docker run -v $(pwd)/html:/var/www/html -e PHP_MEMORY_LIMIT=2G fpfis/httpd-php:5 ## Runtime docker configuration -| env | Description | Default | -|----------------------------|------------------------------------|-------------------| -|`APACHE_ACCESS_LOG` | Location of apache's access log | `/proc/self/fd/1` | -|`APACHE_ERROR_LOG` | Location of apache's error log | `/proc/self/fd/2` | -|`DAEMON_GROUP` | Group name to run the daemons with | `www-data` | -|`DAEMON_USER` | Username to run the daemons with | `www-data` | -|`DOCUMENT_ROOT` | Document root | `/var/www/html` | +| env | Description | Default +|----------------------------|------------------------------------|----------- +|`APACHE_ACCESS_LOG` | Location of apache's access log | `/proc/self/fd/1` +|`APACHE_ERROR_LOG` | Location of apache's error log | `/proc/self/fd/2` +|`DAEMON_GROUP` | Group name to run the daemons with | `www-data` +|`DAEMON_USER` | Username to run the daemons with | `www-data` +|`DOCUMENT_ROOT` | Document root | `/var/www/html` |`SITE_PATH` | Site URL location (non-dev) | `/` -|`FPM_MAX_CHILDREN` | Max number of PHP processes | `5` | -|`FPM_MIN_CHILDREN` | Min number of PHP processes | `2` | -|`HTTP_PORT` | Port to listen on | `8080` | -|`PHP_MAX_EXECUTION_TIME` | PHP max execution time | `30` | -|`PHP_MAX_INPUT_TIME` | PHP max input time | `30` | -|`PHP_MEMORY_LIMIT` | PHP memory limit | `512M` | +|`FPM_MAX_CHILDREN` | Max number of PHP processes | `5` +|`FPM_MIN_CHILDREN` | Min number of PHP processes | `2` +|`HTTP_PORT` | Port to listen on | `8080` +|`PHP_MAX_EXECUTION_TIME` | PHP max execution time | `30` +|`PHP_MAX_INPUT_TIME` | PHP max input time | `30` +|`PHP_MEMORY_LIMIT` | PHP memory limit | `512M` |`SMTP_SERVER` | SMTP server to use | empty |`SMTP_PORT ` | SMTP port to use | `25` |`SMTP_FROM` | SMTP From to use | empty diff --git a/docker-compose.yaml b/docker-compose.yaml index ac16cc0..3949813 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -9,6 +9,8 @@ services: environment: - SMTP_SERVER=mailhog - SMTP_PORT=1025 + - SYSLOG_SERVER_IP=web + - SYSLOG_SERVER_PORT=514 ports: - 8080:8080 volumes: diff --git a/rsyslog_conf/rsyslog.conf b/rsyslog_conf/rsyslog.conf new file mode 100644 index 0000000..ca5c2f7 --- /dev/null +++ b/rsyslog_conf/rsyslog.conf @@ -0,0 +1,103 @@ +# /etc/rsyslog.conf Configuration file for rsyslog. +# +# For more information see +# /usr/share/doc/rsyslog-doc/html/rsyslog_conf.html +# +# Default logging rules can be found in /etc/rsyslog.d/50-default.conf + + +################# +#### MODULES #### +################# + +module(load="imuxsock") # provides support for local system logging +#module(load="immark") # provides --MARK-- message capability + +# provides UDP syslog reception +#module(load="imudp") +#input(type="imudp" port="514") + +# provides TCP syslog reception +#module(load="imtcp") +#input(type="imtcp" port="514") + +# provides kernel logging support and enable non-kernel klog messages +# module(load="imklog" permitnonkernelfacility="on") + +########################### +#### GLOBAL DIRECTIVES #### +########################### + +# +# Use traditional timestamp format. +# To enable high precision timestamps, comment out the following line. +# +$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat + +# Filter duplicated messages +$RepeatedMsgReduction on + +# +# Set the default permissions for all log files. +# +$FileOwner ${DAEMON_USER} +$FileGroup ${DAEMON_USER} +$FileCreateMode 0640 +$DirCreateMode 0755 +$Umask 0022 +$PrivDropToUser syslog +$PrivDropToGroup syslog + +########################### +#### CUSTOM DIRECTIVES #### +########################### + +# +# Where to place spool and state files +# +$WorkDirectory /var/spool/rsyslog + +$OmitLocalLogging off + +# +# APACHE +# +module(load="imfile" PollingInterval="10") + +# Apache access file: +input(type="imfile" + File="/var/log/apache2/access.log" + Tag="apache-access" + Severity="info") + +# Apache error file: +input(type="imfile" + File="/var/log/apache2/error.log" + Tag="apache-error" + Severity="info") + +# PHP out file: +input(type="imfile" + File="/var/log/php/out.log" + Tag="php-out" + Severity="info") + +# PHP error file: +input(type="imfile" + File="/var/log/php/error.log" + Tag="php-error" + Severity="info") + +# +# Custom code for graylog. +# +$ActionQueueType LinkedList # use asynchronous processing +$ActionQueueFileName srvrfwd # set file name, also enables disk mode +$ActionResumeRetryCount -1 # infinite retries on insert failure +$ActionQueueSaveOnShutdown on # save in-memory data if rsyslog shuts down +*.* @@${SYSLOG_SERVER_IP}:${SYSLOG_SERVER_PORT};RSYSLOG_SyslogProtocol23Format + +# +# Include all config files in /etc/rsyslog.d/ +# +$IncludeConfig /etc/rsyslog.d/*.conf \ No newline at end of file diff --git a/scripts/install-base.sh b/scripts/install-base.sh index f341ffa..75c99ae 100755 --- a/scripts/install-base.sh +++ b/scripts/install-base.sh @@ -21,11 +21,12 @@ fi modules=$(printf "php${php_version}-%s " ${php_modules}) -apt-get install -y apache2 php${php_version}-fpm ${modules} msmtp +apt-get install -y apache2 php${php_version}-fpm ${modules} msmtp rsyslog apt-get autoremove software-properties-common -y --purge apt-get clean rm -rf /var/lib/apt/lists/* +rm -rf /tmp/* ln -s /bin/true /usr/sbin/sendmail diff --git a/scripts/install-dev.sh b/scripts/install-dev.sh index 1eb0b99..592face 100755 --- a/scripts/install-dev.sh +++ b/scripts/install-dev.sh @@ -33,7 +33,6 @@ yarn add --cache-folder /tmp wetty.js #sed -i '0,/false/{s/false/true/}' /var/www/webconsole/index.php #rm -f /tmp/webconsole.zip - apt-get clean rm -rf /var/lib/apt/lists/* rm -rf /tmp/* diff --git a/supervisor_conf/syslog.conf b/supervisor_conf/syslog.conf new file mode 100644 index 0000000..95e9ea0 --- /dev/null +++ b/supervisor_conf/syslog.conf @@ -0,0 +1,9 @@ +[program:rsyslog] +command=/usr/sbin/rsyslogd +killasgroup=true +stopasgroup=true +stopsignal=INT +stdout_logfile=/var/log/rsyslog/access.log, /dev/stdout +stdout_logfile_maxbytes=1GB +stderr_logfile=/var/log/rsyslog/error.log, /dev/stderr +stderr_logfile_maxbytes=1GB \ No newline at end of file