Configuration from environment variables

This commit is contained in:
janga 2015-08-11 12:16:19 +01:00
Родитель b82a9e37fc
Коммит 33bb384ac8
79 изменённых файлов: 1770 добавлений и 6 удалений

Просмотреть файл

@ -0,0 +1,48 @@
#!/bin/bash
set -e
set -u
# Supervisord default params
SUPERVISOR_PARAMS='-c /etc/supervisord.conf'
# Create directories for supervisor's UNIX socket and logs (which might be missing
# as container might start with /data mounted from another data-container).
mkdir -p /data/conf /data/run /data/logs
chmod 711 /data/conf /data/run /data/logs
if [ "$(ls /config/init/)" ]; then
for init in /config/init/*.sh; do
. $init
done
fi
# We have TTY, so probably an interactive container...
if test -t 0; then
# Run supervisord detached...
supervisord $SUPERVISOR_PARAMS
# Some command(s) has been passed to container? Execute them and exit.
# No commands provided? Run bash.
if [[ $@ ]]; then
eval $@
else
export PS1='[\u@\h : \w]\$ '
/bin/bash
fi
# Detached mode? Run supervisord in foreground, which will stay until container is stopped.
else
# If some extra params were passed, execute them before.
# @TODO It is a bit confusing that the passed command runs *before* supervisord,
# while in interactive mode they run *after* supervisor.
# Not sure about that, but maybe when any command is passed to container,
# it should be executed *always* after supervisord? And when the command ends,
# container exits as well.
if [[ $@ ]]; then
eval $@
fi
supervisord -n $SUPERVISOR_PARAMS
fi

Просмотреть файл

@ -0,0 +1,13 @@
#!/bin/sh
#
# This script will be placed in /config/init/ and run when container starts.
# It creates (if they're not exist yet) necessary Nginx directories
# @see /etc/nginx/addon.d/fastcgi-cache.example
#
set -e
mkdir -p /run/user/nginx-cache
mkdir -p /run/user/nginx-cache-tmp
chown -R www:www /run/user/nginx-cache*

Просмотреть файл

@ -0,0 +1,20 @@
#!/bin/sh
#
# This script will be placed in /config/init/ and run when container starts.
# It creates (if they're not exist yet) necessary directories
# from where custom Nginx configs can be loaded (from mounted /data volumes).
#
set -e
mkdir -p /data/conf/nginx/addon.d
mkdir -p /data/conf/nginx/conf.d
mkdir -p /data/conf/nginx/hosts.d
mkdir -p /data/conf/nginx/nginx.d
chmod 711 /data/conf/nginx
mkdir -p /data/www/default
echo "default vhost # created on $(date)" > /data/www/default/index.html
chown -R www:www /data/www

Просмотреть файл

@ -0,0 +1,21 @@
#!/bin/sh
#
# Configure internal transparent proxy on specified port (SET_INTERNAL_PROXY_ON_PORT)
# which redirect all traffic to localhost:80. See README for more info.
#
PROXY_SOURCE_CONF="/config/init/vhost-proxy.conf"
PROXY_SOURCE_CONF_HTTPS="/config/init/vhost-proxy-https.conf"
PROXY_TARGET_CONF="/etc/nginx/hosts.d/internal-proxy.conf"
PROXY_TARGET_CONF_HTTPS="/etc/nginx/hosts.d/internal-proxy-https.conf"
if [ ! -z "${SET_INTERNAL_PROXY_ON_PORT+xxx}" ] && [ ! -z "${SET_INTERNAL_PROXY_ON_PORT}" ]; then
cat $PROXY_SOURCE_CONF | sed "s/%proxy_port%/$SET_INTERNAL_PROXY_ON_PORT/g" > $PROXY_TARGET_CONF
echo "Nginx: internal proxy set on port :$SET_INTERNAL_PROXY_ON_PORT."; echo
fi
if [ ! -z "${SET_INTERNAL_HTTPS_PROXY_ON_PORT+xxx}" ] && [ ! -z "${SET_INTERNAL_HTTPS_PROXY_ON_PORT}" ]; then
cat $PROXY_SOURCE_CONF_HTTPS | sed "s/%proxy_port%/$SET_INTERNAL_HTTPS_PROXY_ON_PORT/g" > $PROXY_TARGET_CONF_HTTPS
echo "Nginx: internal HTTPS proxy set on port :$SET_INTERNAL_HTTPS_PROXY_ON_PORT."; echo
fi

Просмотреть файл

@ -0,0 +1,6 @@
#!/bin/sh
#
# Configure access IP address for nginx status page under /nginx_status
#
sed -i "s|allow 127.0.0.1|allow ${STATUS_PAGE_ALLOWED_IP}|g" /etc/nginx/conf.d/stub-status.conf
echo "Nginx status page: allowed address set to $STATUS_PAGE_ALLOWED_IP."

Просмотреть файл

@ -0,0 +1,6 @@
#!/bin/sh
#
# Configure access IP address for PHP-FPM satus page under /fpm_status
#
sed -i "s|allow 127.0.0.1|allow ${STATUS_PAGE_ALLOWED_IP}|g" /etc/nginx/conf.d/fpm-status.conf
echo "PHP-FPM status page: allowed address set to $STATUS_PAGE_ALLOWED_IP."

Просмотреть файл

@ -0,0 +1,14 @@
# Internal proxy, HTTPS version
server {
listen %proxy_port% ssl;
ssl_certificate /etc/nginx/ssl/dummy.crt;
ssl_certificate_key /etc/nginx/ssl/dummy.key;
location / {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect off;
proxy_pass https://127.0.0.1:443;
}
}

Просмотреть файл

@ -0,0 +1,11 @@
# Internal proxy, HTTP version
server {
listen %proxy_port%;
location / {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect off;
proxy_pass http://127.0.0.1:80;
}
}

Просмотреть файл

@ -0,0 +1,23 @@
#
# Pre-configured FastCGI cache.
# It's not used until specified in location {} context.
#
# Usage: rename this file to fastcgi-cache.conf
# and your vhost config add something like this:
# location ~ \.php$ {
# include fastcgi_params;
# fastcgi_pass php-upstream;
# fastcgi_cache APPCACHE;
# fastcgi_cache_valid 60m;
# }
#
# To achieve best performance, mount /run (or /var/run)
# which is usually tmpfs memory drive, into your docker container:
# docker run ... -v /run/user/my-container:/run/user ...
#
fastcgi_cache_path /run/user/nginx-cache levels=1:2 keys_zone=APPCACHE:10m inactive=120m;
fastcgi_temp_path /run/user/nginx-cache-tmp;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
fastcgi_cache_use_stale error timeout invalid_header http_500;
fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
fastcgi_cache_lock on;

Просмотреть файл

@ -0,0 +1,3 @@
set_real_ip_from 127.0.0.1;
real_ip_header X-Forwarded-For;
real_ip_recursive off;

Просмотреть файл

@ -0,0 +1,3 @@
upstream php-upstream {
server unix:/var/run/php-fpm-www.sock;
}

Просмотреть файл

@ -0,0 +1,5 @@
# no access to .hidden files (eg .htaccess)
location ~ /\. {
deny all;
log_not_found off;
}

Просмотреть файл

@ -0,0 +1,8 @@
# static content:
# - images
# - flash
# - fonts
# - css/js
location ~* \.(?:jpe?g|gif|png|ico|swf|svg|eot|ttf|otf|woff|htc|css|js)$ {
expires max;
}

Просмотреть файл

@ -0,0 +1,8 @@
location = /favicon.ico {
log_not_found off;
}
location = /robots.txt {
allow all;
log_not_found off;
}

Просмотреть файл

@ -0,0 +1,8 @@
location /fpm_status {
access_log off;
allow 127.0.0.1;
deny all;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass php-upstream;
}

Просмотреть файл

@ -0,0 +1,4 @@
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass php-upstream;
}

Просмотреть файл

@ -0,0 +1,5 @@
location /nginx_status {
stub_status;
allow 127.0.0.1;
deny all;
}

Просмотреть файл

@ -0,0 +1,44 @@
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param HTTPS $https if_not_empty;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
# SERVER_PORT needs to be commented out and has to be determined from other fields (e.g. HTTP_HOST)
# Otherwise it points invalid port when container port is mapped to different port on host machine,
# which might result with invalid links generated in a PHP app.
#fastcgi_param SERVER_PORT $server_port;
# Using $http_host instead of $server_name - $server_name doesn't work correctly when using regexps in vhosts' server_name declaration.
#fastcgi_param SERVER_NAME $server_name;
fastcgi_param SERVER_NAME $http_host;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
fastcgi_index index.php;
fastcgi_connect_timeout 10;
fastcgi_send_timeout 600;
fastcgi_read_timeout 600;
fastcgi_buffer_size 32k;
fastcgi_buffers 32 4k;
fastcgi_busy_buffers_size 64k;
fastcgi_temp_file_write_size 256k;
fastcgi_intercept_errors on;
fastcgi_pass_header on;
fastcgi_keep_conn on;

Просмотреть файл

@ -0,0 +1,17 @@
server {
listen 80 default;
root /data/www/default;
index index.php index.html;
include /etc/nginx/conf.d/default-*.conf;
include /data/conf/nginx/conf.d/default-*.conf;
# PHP backend is not in the default-*.conf file set,
# as some vhost might not want to include it.
include /etc/nginx/conf.d/php-location.conf;
# Import configuration files for status pages for Nginx and PHP-FPM
include /etc/nginx/conf.d/stub-status.conf;
include /etc/nginx/conf.d/fpm-status.conf;
}

Просмотреть файл

@ -0,0 +1,27 @@
daemon off;
pid /var/run/nginx.pid;
user www;
error_log stderr notice;
worker_processes auto;
events {
multi_accept on;
use epoll;
worker_connections 1024;
}
http {
# Somehow it's not inherited by vhosts (server{} context) when using with 'stderr' value.
# Therefore it's re-defined here to avoid specyfing it for each vhost.
error_log stderr notice;
include /etc/nginx/nginx.d/*.conf;
include /data/conf/nginx/nginx.d/*.conf;
include /etc/nginx/addon.d/*.conf;
include /data/conf/nginx/addon.d/*.conf;
include /etc/nginx/hosts.d/*.conf;
include /data/conf/nginx/hosts.d/*.conf;
}

Просмотреть файл

@ -0,0 +1,2 @@
include /etc/nginx/mime.types;
default_type application/octet-stream;

Просмотреть файл

@ -0,0 +1,2 @@
access_log off;
error_log /data/logs/nginx-error.log;

Просмотреть файл

@ -0,0 +1,9 @@
gzip on;
gzip_http_version 1.0;
gzip_comp_level 4;
gzip_min_length 1024;
gzip_proxied any;
gzip_vary off;
gzip_types text/plain text/css application/x-javascript text/xml application/xml application/rss+xml application/atom+xml text/javascript application/javascript application/json text/mathml;
gzip_static on;

Просмотреть файл

@ -0,0 +1,7 @@
# Increase buffer size for client requests (incl. file uploads)
# so uploading the file up to xMB won't result with Nginx warning:
# "a client request body is buffered to a temporary file ..."
client_body_buffer_size 5M;
# Set max upload size
client_max_body_size 256M;

Просмотреть файл

@ -0,0 +1,5 @@
# Increase slightly proxy buffer size and amount so it can
# handle up to 512KB into the memory (vs. default 32|64kB).
# Only used when proxy_pass directive is in place.
proxy_buffer_size 32k;
proxy_buffers 16 32k;

Просмотреть файл

@ -0,0 +1,12 @@
server_tokens off;
sendfile on;
server_names_hash_bucket_size 128;
types_hash_max_size 2048;
types_hash_bucket_size 64;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 15;

Просмотреть файл

@ -0,0 +1,7 @@
include=/etc/php-fpm.d/*.conf
[global]
daemonize = no
pid = /var/run/php-fpm.pid
error_log = /data/logs/php-fpm-daemon.log
log_level = warning

Просмотреть файл

@ -0,0 +1,18 @@
[www]
user = www
listen = /var/run/php-fpm-www.sock
listen.owner = www
pm = ondemand
pm.max_children = 10
pm.max_requests = 500
pm.process_idle_timeout = 10s
pm.status_path = /fpm_status
ping.path = /ping
slowlog = /data/logs/php-fpm-slow.log
request_slowlog_timeout = 60
catch_workers_output = yes
include = /data/conf/php-fpm-www-*.conf

Просмотреть файл

@ -0,0 +1,4 @@
; Completely switch off populating $HTTP_RAW_POST_DATA
; to remove the warning about deprecated usage.
; http://php.net/manual/en/ini.core.php#ini.always-populate-raw-post-data
always_populate_raw_post_data = -1

Просмотреть файл

@ -0,0 +1,19 @@
; Basic configuration override
expose_php = Off
memory_limit = 512M
post_max_size = 128M
upload_max_filesize = 128M
date.timezone = GMT
max_execution_time = 120
; Error reporting
display_errors = On
display_startup_errors = On
; A bit of performance tuning
realpath_cache_size = 128k
; OpCache tuning
opcache.max_accelerated_files = 32000
opcache.memory_consumption = 128
opcache.fast_shutdown = 0

Просмотреть файл

@ -0,0 +1,9 @@
[program:nginx]
command = /usr/sbin/nginx
autorestart = true
stderr_logfile = NONE
stdout_logfile = NONE
# Watch for changes in Nginx conf directories and restart Nginx when a config change occured
[program:nginx-reload]
command=bash -c 'while inotifywait -q -r -e create,delete,modify,move,attrib --exclude "/\." /etc/nginx/ /data/conf/nginx/; do nginx -t && nginx -s reload; done'

Просмотреть файл

@ -0,0 +1,5 @@
[program:php-fpm]
command = php-fpm
autorestart = true
stdout_logfile = /data/logs/php-fpm.log
stderr_logfile = /data/logs/php-fpm.log

Просмотреть файл

@ -0,0 +1,24 @@
[supervisord]
pidfile = /run/supervisord.pid
# It seems that it's not possible to swith this log to NONE (it creates NONE logfile)
logfile = /data/logs/supervisord.log
# Set loglevel=debug, only then all logs from child services are printed out
# to container logs (and thus available via `docker logs [container]`
loglevel = debug
# These two (unix_http_server, rpcinterface) are needed for supervisorctl to work
[inet_http_server]
port = :9111
username = sv
password = password
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl = http://localhost:9111
username = sv
password = password
[include]
files = /etc/supervisor.d/*.conf

Просмотреть файл

@ -0,0 +1,6 @@
from zabbix.api import ZabbixAPI
zapi = ZabbixAPI(url='http://localhost/', user='Admin', password='zabbix')
hosts = zapi.host.getobjects(status=1)
for host in hosts:
print 'Enabling host: %s' % host['name']
zapi.host.update(hostid=host['hostid'],status=0)

Просмотреть файл

@ -8,13 +8,71 @@ ENV \
STATUS_PAGE_ALLOWED_IP=127.0.0.1 \
JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk/bin/java \
JAVA=/usr/lib/jvm/java-1.8.0-openjdk/bin/java \
DB_ADDR=zabbix.db \
DB_USER=admin \
DB_PASS=password \
DB_PORT=3306 \
DB_NAME=zabbix \
PHP_TIMEZONE=UTC \
DEBUG_LEVEL=3
ZS_ListenPort=10051 \
ZS_SourceIP='' \
ZS_LogFile=/tmp/zabbix_server.log \
ZS_LogFileSize=10 \
ZS_DebugLevel=3 \
ZS_PidFile=/var/run/zabbix_server.pid \
ZS_DBHost=zabbix.db \
ZS_DBName=zabbix \
ZS_DBSchema='' \
ZS_DBUser=zabbix \
ZS_DBPassword=zabbix \
ZS_DBSocket=/tmp/mysql.sock \
ZS_DBPort=3306 \
ZS_StartPollers=5 \
ZS_StartPollersUnreachable=1 \
ZS_StartTrappers=5 \
ZS_StartPingers=1 \
ZS_StartDiscoverers=1 \
ZS_StartHTTPPollers=1 \
ZS_StartTimers=1 \
ZS_JavaGateway=127.0.0.1 \
ZS_JavaGatewayPort=10052 \
ZS_StartJavaPollers=0 \
ZS_StartVMwareCollectors=0 \
ZS_VMwareFrequency=60 \
ZS_VMwarePerfFrequency=60 \
ZS_VMwareCacheSize=8M \
ZS_VMwareTimeout=10 \
ZS_SNMPTrapperFile=/tmp/zabbix_traps.tmp \
ZS_StartSNMPTrapper=0 \
ZS_ListenIP=0.0.0.0 \
ZS_HousekeepingFrequency=1 \
ZS_MaxHousekeeperDelete=500 \
ZS_SenderFrequency=30 \
ZS_CacheSize=8M \
ZS_CacheUpdateFrequency=60 \
ZS_StartDBSyncers=4 \
ZS_HistoryCacheSize=8M \
ZS_TrendCacheSize=4M \
ZS_HistoryTextCacheSize=16MB \
ZS_ValueCacheSize=8M \
ZS_Timeout=3 \
ZS_TrapperTimeout=300 \
ZS_UnreachablePeriod=45 \
ZS_UnavailableDelay=60 \
ZS_UnreachableDelay=15 \
ZS_AlertScriptsPath=${datadir}/zabbix/alertscripts \
ZS_ExternalScripts=${datadir}/zabbix/externalscripts \
ZS_FpingLocation=/usr/sbin/fping \
ZS_Fping6Location=/usr/sbin/fping6 \
ZS_SSHKeyLocation='' \
ZS_LogSlowQueries=0 \
ZS_TmpDir=/tmp \
ZS_StartProxyPollers=1 \
ZS_ProxyConfigFrequency=3600 \
ZS_ProxyDataFrequency=1 \
ZS_AllowRoot=0 \
ZS_User=zabbix \
ZS_Include='' \
ZS_SSLCertLocation=${datadir}/zabbix/ssl/certs \
ZS_SSLKeyLocation=${datadir}/zabbix/ssl/keys \
ZS_SSLCALocation='' \
ZS_LoadModulePath=${libdir}/modules \
ZS_LoadModule=''
# Layer: base
RUN \

Просмотреть файл

@ -0,0 +1,48 @@
#!/bin/bash
set -e
set -u
# Supervisord default params
SUPERVISOR_PARAMS='-c /etc/supervisord.conf'
# Create directories for supervisor's UNIX socket and logs (which might be missing
# as container might start with /data mounted from another data-container).
mkdir -p /data/conf /data/run /data/logs
chmod 711 /data/conf /data/run /data/logs
if [ "$(ls /config/init/)" ]; then
for init in /config/init/*.sh; do
. $init
done
fi
# We have TTY, so probably an interactive container...
if test -t 0; then
# Run supervisord detached...
supervisord $SUPERVISOR_PARAMS
# Some command(s) has been passed to container? Execute them and exit.
# No commands provided? Run bash.
if [[ $@ ]]; then
eval $@
else
export PS1='[\u@\h : \w]\$ '
/bin/bash
fi
# Detached mode? Run supervisord in foreground, which will stay until container is stopped.
else
# If some extra params were passed, execute them before.
# @TODO It is a bit confusing that the passed command runs *before* supervisord,
# while in interactive mode they run *after* supervisor.
# Not sure about that, but maybe when any command is passed to container,
# it should be executed *always* after supervisord? And when the command ends,
# container exits as well.
if [[ $@ ]]; then
eval $@
fi
supervisord -n $SUPERVISOR_PARAMS
fi

Просмотреть файл

@ -0,0 +1,13 @@
#!/bin/sh
#
# This script will be placed in /config/init/ and run when container starts.
# It creates (if they're not exist yet) necessary Nginx directories
# @see /etc/nginx/addon.d/fastcgi-cache.example
#
set -e
mkdir -p /run/user/nginx-cache
mkdir -p /run/user/nginx-cache-tmp
chown -R www:www /run/user/nginx-cache*

Просмотреть файл

@ -0,0 +1,20 @@
#!/bin/sh
#
# This script will be placed in /config/init/ and run when container starts.
# It creates (if they're not exist yet) necessary directories
# from where custom Nginx configs can be loaded (from mounted /data volumes).
#
set -e
mkdir -p /data/conf/nginx/addon.d
mkdir -p /data/conf/nginx/conf.d
mkdir -p /data/conf/nginx/hosts.d
mkdir -p /data/conf/nginx/nginx.d
chmod 711 /data/conf/nginx
mkdir -p /data/www/default
echo "default vhost # created on $(date)" > /data/www/default/index.html
chown -R www:www /data/www

Просмотреть файл

@ -0,0 +1,21 @@
#!/bin/sh
#
# Configure internal transparent proxy on specified port (SET_INTERNAL_PROXY_ON_PORT)
# which redirect all traffic to localhost:80. See README for more info.
#
PROXY_SOURCE_CONF="/config/init/vhost-proxy.conf"
PROXY_SOURCE_CONF_HTTPS="/config/init/vhost-proxy-https.conf"
PROXY_TARGET_CONF="/etc/nginx/hosts.d/internal-proxy.conf"
PROXY_TARGET_CONF_HTTPS="/etc/nginx/hosts.d/internal-proxy-https.conf"
if [ ! -z "${SET_INTERNAL_PROXY_ON_PORT+xxx}" ] && [ ! -z "${SET_INTERNAL_PROXY_ON_PORT}" ]; then
cat $PROXY_SOURCE_CONF | sed "s/%proxy_port%/$SET_INTERNAL_PROXY_ON_PORT/g" > $PROXY_TARGET_CONF
echo "Nginx: internal proxy set on port :$SET_INTERNAL_PROXY_ON_PORT."; echo
fi
if [ ! -z "${SET_INTERNAL_HTTPS_PROXY_ON_PORT+xxx}" ] && [ ! -z "${SET_INTERNAL_HTTPS_PROXY_ON_PORT}" ]; then
cat $PROXY_SOURCE_CONF_HTTPS | sed "s/%proxy_port%/$SET_INTERNAL_HTTPS_PROXY_ON_PORT/g" > $PROXY_TARGET_CONF_HTTPS
echo "Nginx: internal HTTPS proxy set on port :$SET_INTERNAL_HTTPS_PROXY_ON_PORT."; echo
fi

Просмотреть файл

@ -0,0 +1,6 @@
#!/bin/sh
#
# Configure access IP address for nginx status page under /nginx_status
#
sed -i "s|allow 127.0.0.1|allow ${STATUS_PAGE_ALLOWED_IP}|g" /etc/nginx/conf.d/stub-status.conf
echo "Nginx status page: allowed address set to $STATUS_PAGE_ALLOWED_IP."

Просмотреть файл

@ -0,0 +1,6 @@
#!/bin/sh
#
# Configure access IP address for PHP-FPM satus page under /fpm_status
#
sed -i "s|allow 127.0.0.1|allow ${STATUS_PAGE_ALLOWED_IP}|g" /etc/nginx/conf.d/fpm-status.conf
echo "PHP-FPM status page: allowed address set to $STATUS_PAGE_ALLOWED_IP."

Просмотреть файл

@ -0,0 +1,14 @@
# Internal proxy, HTTPS version
server {
listen %proxy_port% ssl;
ssl_certificate /etc/nginx/ssl/dummy.crt;
ssl_certificate_key /etc/nginx/ssl/dummy.key;
location / {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect off;
proxy_pass https://127.0.0.1:443;
}
}

Просмотреть файл

@ -0,0 +1,11 @@
# Internal proxy, HTTP version
server {
listen %proxy_port%;
location / {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect off;
proxy_pass http://127.0.0.1:80;
}
}

Просмотреть файл

@ -0,0 +1,23 @@
#
# Pre-configured FastCGI cache.
# It's not used until specified in location {} context.
#
# Usage: rename this file to fastcgi-cache.conf
# and your vhost config add something like this:
# location ~ \.php$ {
# include fastcgi_params;
# fastcgi_pass php-upstream;
# fastcgi_cache APPCACHE;
# fastcgi_cache_valid 60m;
# }
#
# To achieve best performance, mount /run (or /var/run)
# which is usually tmpfs memory drive, into your docker container:
# docker run ... -v /run/user/my-container:/run/user ...
#
fastcgi_cache_path /run/user/nginx-cache levels=1:2 keys_zone=APPCACHE:10m inactive=120m;
fastcgi_temp_path /run/user/nginx-cache-tmp;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
fastcgi_cache_use_stale error timeout invalid_header http_500;
fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
fastcgi_cache_lock on;

Просмотреть файл

@ -0,0 +1,3 @@
set_real_ip_from 127.0.0.1;
real_ip_header X-Forwarded-For;
real_ip_recursive off;

Просмотреть файл

@ -0,0 +1,3 @@
upstream php-upstream {
server unix:/var/run/php-fpm-www.sock;
}

Просмотреть файл

@ -0,0 +1,5 @@
# no access to .hidden files (eg .htaccess)
location ~ /\. {
deny all;
log_not_found off;
}

Просмотреть файл

@ -0,0 +1,8 @@
# static content:
# - images
# - flash
# - fonts
# - css/js
location ~* \.(?:jpe?g|gif|png|ico|swf|svg|eot|ttf|otf|woff|htc|css|js)$ {
expires max;
}

Просмотреть файл

@ -0,0 +1,8 @@
location = /favicon.ico {
log_not_found off;
}
location = /robots.txt {
allow all;
log_not_found off;
}

Просмотреть файл

@ -0,0 +1,8 @@
location /fpm_status {
access_log off;
allow 127.0.0.1;
deny all;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass php-upstream;
}

Просмотреть файл

@ -0,0 +1,4 @@
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass php-upstream;
}

Просмотреть файл

@ -0,0 +1,5 @@
location /nginx_status {
stub_status;
allow 127.0.0.1;
deny all;
}

Просмотреть файл

@ -0,0 +1,44 @@
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param HTTPS $https if_not_empty;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
# SERVER_PORT needs to be commented out and has to be determined from other fields (e.g. HTTP_HOST)
# Otherwise it points invalid port when container port is mapped to different port on host machine,
# which might result with invalid links generated in a PHP app.
#fastcgi_param SERVER_PORT $server_port;
# Using $http_host instead of $server_name - $server_name doesn't work correctly when using regexps in vhosts' server_name declaration.
#fastcgi_param SERVER_NAME $server_name;
fastcgi_param SERVER_NAME $http_host;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
fastcgi_index index.php;
fastcgi_connect_timeout 10;
fastcgi_send_timeout 600;
fastcgi_read_timeout 600;
fastcgi_buffer_size 32k;
fastcgi_buffers 32 4k;
fastcgi_busy_buffers_size 64k;
fastcgi_temp_file_write_size 256k;
fastcgi_intercept_errors on;
fastcgi_pass_header on;
fastcgi_keep_conn on;

Просмотреть файл

@ -0,0 +1,17 @@
server {
listen 80 default;
root /data/www/default;
index index.php index.html;
include /etc/nginx/conf.d/default-*.conf;
include /data/conf/nginx/conf.d/default-*.conf;
# PHP backend is not in the default-*.conf file set,
# as some vhost might not want to include it.
include /etc/nginx/conf.d/php-location.conf;
# Import configuration files for status pages for Nginx and PHP-FPM
include /etc/nginx/conf.d/stub-status.conf;
include /etc/nginx/conf.d/fpm-status.conf;
}

Просмотреть файл

@ -0,0 +1,27 @@
daemon off;
pid /var/run/nginx.pid;
user www;
error_log stderr notice;
worker_processes auto;
events {
multi_accept on;
use epoll;
worker_connections 1024;
}
http {
# Somehow it's not inherited by vhosts (server{} context) when using with 'stderr' value.
# Therefore it's re-defined here to avoid specyfing it for each vhost.
error_log stderr notice;
include /etc/nginx/nginx.d/*.conf;
include /data/conf/nginx/nginx.d/*.conf;
include /etc/nginx/addon.d/*.conf;
include /data/conf/nginx/addon.d/*.conf;
include /etc/nginx/hosts.d/*.conf;
include /data/conf/nginx/hosts.d/*.conf;
}

Просмотреть файл

@ -0,0 +1,2 @@
include /etc/nginx/mime.types;
default_type application/octet-stream;

Просмотреть файл

@ -0,0 +1,2 @@
access_log off;
error_log /data/logs/nginx-error.log;

Просмотреть файл

@ -0,0 +1,9 @@
gzip on;
gzip_http_version 1.0;
gzip_comp_level 4;
gzip_min_length 1024;
gzip_proxied any;
gzip_vary off;
gzip_types text/plain text/css application/x-javascript text/xml application/xml application/rss+xml application/atom+xml text/javascript application/javascript application/json text/mathml;
gzip_static on;

Просмотреть файл

@ -0,0 +1,7 @@
# Increase buffer size for client requests (incl. file uploads)
# so uploading the file up to xMB won't result with Nginx warning:
# "a client request body is buffered to a temporary file ..."
client_body_buffer_size 5M;
# Set max upload size
client_max_body_size 256M;

Просмотреть файл

@ -0,0 +1,5 @@
# Increase slightly proxy buffer size and amount so it can
# handle up to 512KB into the memory (vs. default 32|64kB).
# Only used when proxy_pass directive is in place.
proxy_buffer_size 32k;
proxy_buffers 16 32k;

Просмотреть файл

@ -0,0 +1,12 @@
server_tokens off;
sendfile on;
server_names_hash_bucket_size 128;
types_hash_max_size 2048;
types_hash_bucket_size 64;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 15;

Просмотреть файл

@ -0,0 +1,7 @@
include=/etc/php-fpm.d/*.conf
[global]
daemonize = no
pid = /var/run/php-fpm.pid
error_log = /data/logs/php-fpm-daemon.log
log_level = warning

Просмотреть файл

@ -0,0 +1,18 @@
[www]
user = www
listen = /var/run/php-fpm-www.sock
listen.owner = www
pm = ondemand
pm.max_children = 10
pm.max_requests = 500
pm.process_idle_timeout = 10s
pm.status_path = /fpm_status
ping.path = /ping
slowlog = /data/logs/php-fpm-slow.log
request_slowlog_timeout = 60
catch_workers_output = yes
include = /data/conf/php-fpm-www-*.conf

Просмотреть файл

@ -0,0 +1,4 @@
; Completely switch off populating $HTTP_RAW_POST_DATA
; to remove the warning about deprecated usage.
; http://php.net/manual/en/ini.core.php#ini.always-populate-raw-post-data
always_populate_raw_post_data = -1

Просмотреть файл

@ -0,0 +1,19 @@
; Basic configuration override
expose_php = Off
memory_limit = 512M
post_max_size = 128M
upload_max_filesize = 128M
date.timezone = GMT
max_execution_time = 120
; Error reporting
display_errors = On
display_startup_errors = On
; A bit of performance tuning
realpath_cache_size = 128k
; OpCache tuning
opcache.max_accelerated_files = 32000
opcache.memory_consumption = 128
opcache.fast_shutdown = 0

Просмотреть файл

@ -0,0 +1,9 @@
[program:nginx]
command = /usr/sbin/nginx
autorestart = true
stderr_logfile = NONE
stdout_logfile = NONE
# Watch for changes in Nginx conf directories and restart Nginx when a config change occured
[program:nginx-reload]
command=bash -c 'while inotifywait -q -r -e create,delete,modify,move,attrib --exclude "/\." /etc/nginx/ /data/conf/nginx/; do nginx -t && nginx -s reload; done'

Просмотреть файл

@ -0,0 +1,5 @@
[program:php-fpm]
command = php-fpm
autorestart = true
stdout_logfile = /data/logs/php-fpm.log
stderr_logfile = /data/logs/php-fpm.log

Просмотреть файл

@ -0,0 +1,24 @@
[supervisord]
pidfile = /run/supervisord.pid
# It seems that it's not possible to swith this log to NONE (it creates NONE logfile)
logfile = /data/logs/supervisord.log
# Set loglevel=debug, only then all logs from child services are printed out
# to container logs (and thus available via `docker logs [container]`
loglevel = debug
# These two (unix_http_server, rpcinterface) are needed for supervisorctl to work
[inet_http_server]
port = :9111
username = sv
password = password
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl = http://localhost:9111
username = sv
password = password
[include]
files = /etc/supervisor.d/*.conf

Просмотреть файл

@ -0,0 +1,21 @@
#!/bin/sh
pidfile="$1"
shift
command=$@
# Proxy signals
function kill_app(){
kill $(cat $pidfile)
exit 0 # exit okay
}
trap "kill_app" SIGINT SIGTERM
# Launch daemon
$command
sleep 2
# Loop while the pidfile and the process exist
while [ -f $pidfile ] && kill -0 $(cat $pidfile) ; do
sleep 0.5
done
exit 1000

Просмотреть файл

@ -0,0 +1,147 @@
#!/bin/sh
set -eu
export TERM=xterm
# Bash Colors
red=`tput setaf 1`
green=`tput setaf 2`
yellow=`tput setaf 3`
white=`tput setaf 7`
bold=`tput bold`
reset=`tput sgr0`
separator=$(echo && printf '=%.0s' {1..100} && echo)
# Logging Finctions
log() {
if [[ "$@" ]]; then echo "${bold}${green}[LOG `date +'%T'`]${reset} $@";
else echo; fi
}
warning() {
echo "${bold}${yellow}[WARNING `date +'%T'`]${reset} ${yellow}$@${reset}";
}
error() {
echo "${bold}${red}[ERROR `date +'%T'`]${reset} ${red}$@${reset}";
}
create_db() {
mysql -u ${DB_USER} -p${DB_PASS} -h ${DB_ADDR} -e "CREATE DATABASE IF NOT EXISTS zabbix CHARACTER SET utf8;"
mysql -u ${DB_USER} -p${DB_PASS} -h ${DB_ADDR} -e "GRANT ALL ON zabbix.* TO '${DB_USER}'@'%' identified by '${DB_PASS}';"
mysql -u ${DB_USER} -p${DB_PASS} -h ${DB_ADDR} -e "flush privileges;"
}
import_zabbix_db() {
mysql -u ${DB_USER} -p${DB_PASS} -h ${DB_ADDR} -D zabbix < ${ZABBIX_SQL_DIR}/schema.sql
mysql -u ${DB_USER} -p${DB_PASS} -h ${DB_ADDR} -D zabbix < ${ZABBIX_SQL_DIR}/images.sql
mysql -u ${DB_USER} -p${DB_PASS} -h ${DB_ADDR} -D zabbix < ${ZABBIX_SQL_DIR}/data.sql
}
logging() {
mkdir -p /var/log/zabbix
chmod 777 /var/log/zabbix
touch /var/log/zabbix/zabbix_server.log /var/log/zabbix/zabbix_agentd.log
chmod 777 /var/log/zabbix/zabbix_server.log /var/log/zabbix/zabbix_agentd.log
}
system_pids() {
touch /var/run/zabbix_server.pid /var/run/zabbix_agentd.pid /var/run/zabbix_java.pid
chmod 777 /var/run/zabbix_server.pid /var/run/zabbix_agentd.pid /var/run/zabbix_java.pid
}
fix_permissions() {
getent group zabbix || groupadd zabbix
getent passwd zabbix || useradd -g zabbix -M zabbix
chown -R zabbix:zabbix /usr/local/etc/
chown -R zabbix:zabbix /usr/local/src/zabbix/
mkdir -p /usr/local/src/zabbix/frontends/php/conf/
chmod 777 /usr/local/src/zabbix/frontends/php/conf/
chmod u+s `which ping`
}
update_config() {
sed -i 's/=ZS_ListenPort/='${ZS_ListenPort}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_SourceIP/='${ZS_SourceIP}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_LogFile/='${ZS_LogFile}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_LogFileSize/='${ZS_LogFileSize}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_DebugLevel/='${ZS_DebugLevel}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_PidFile/='${ZS_PidFile}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_DBHost/='${ZS_DBHost}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_DBName/='${ZS_DBName}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_DBSchema/='${ZS_DBSchema}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_DBUser/='${ZS_DBUser}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_DBPassword/='${ZS_DBPassword}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_DBSocket/='${ZS_DBSocket}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_DBPort/='${ZS_DBPort}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_StartPollers/='${ZS_StartPollers}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_StartPollersUnreachable/='${ZS_StartPollersUnreachable}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_StartTrappers/='${ZS_StartTrappers}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_StartPingers/='${ZS_StartPingers}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_StartDiscoverers/='${ZS_StartDiscoverers}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_StartHTTPPollers/='${ZS_StartHTTPPollers}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_StartTimers/='${ZS_StartTimers}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_JavaGateway/='${ZS_JavaGateway}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_JavaGatewayPort/='${ZS_JavaGatewayPort}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_StartJavaPollers/='${ZS_StartJavaPollers}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_StartVMwareCollectors/='${ZS_StartVMwareCollectors}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_VMwareFrequency/='${ZS_VMwareFrequency}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_VMwarePerfFrequency/='${ZS_VMwarePerfFrequency}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_VMwareCacheSize/='${ZS_VMwareCacheSize}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_VMwareTimeout/='${ZS_VMwareTimeout}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_SNMPTrapperFile/='${ZS_SNMPTrapperFile}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_StartSNMPTrapper/='${ZS_StartSNMPTrapper}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_ListenIP/='${ZS_ListenIP}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_HousekeepingFrequency/='${ZS_HousekeepingFrequency}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_MaxHousekeeperDelete/='${ZS_MaxHousekeeperDelete}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_SenderFrequency/='${ZS_SenderFrequency}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_CacheSize/='${ZS_CacheSize}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_CacheUpdateFrequency/='${ZS_CacheUpdateFrequency}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_StartDBSyncers/='${ZS_StartDBSyncers}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_HistoryCacheSize/='${ZS_HistoryCacheSize}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_ValueCacheSize/='${ZS_ValueCacheSize}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_Timeout/='${ZS_Timeout}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_TrapperTimeout/='${ZS_TrapperTimeout}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_UnreachablePeriod/='${ZS_UnreachablePeriod}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_UnavailableDelay/='${ZS_UnavailableDelay}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_UnreachableDelay/='${ZS_UnreachableDelay}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_AlertScriptsPath/='${ZS_AlertScriptsPath}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_ExternalScripts/='${ZS_ExternalScripts}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_FpingLocation/='${ZS_FpingLocation}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_Fping6Location/='${ZS_Fping6Location}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_SSHKeyLocation/='${ZS_SSHKeyLocation}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_LogSlowQueries/='${ZS_LogSlowQueries}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_TmpDir/='${ZS_TmpDir}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_StartProxyPollers/='${ZS_StartProxyPollers}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_ProxyConfigFrequency/='${ZS_ProxyConfigFrequency}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_ProxyDataFrequency/='${ZS_ProxyDataFrequency}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_AllowRoot/='${ZS_AllowRoot}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_User/='${ZS_User}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_Include/='${ZS_Include}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_SSLCertLocation/='${ZS_SSLCertLocation}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_SSLKeyLocation/='${ZS_SSLKeyLocation}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_SSLCALocation/='${ZS_SSLCALocation}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_LoadModulePath/='${ZS_LoadModulePath}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/=ZS_LoadModule/='${ZS_LoadModule}'/g' /usr/local/etc/zabbix_server.conf
sed -i 's/ZS_DBHost/'${ZS_DBHost}'/g' /usr/local/src/zabbix/frontends/php/conf/zabbix.conf.php
sed -i 's/ZS_DBUser/'${ZS_DBUser}'/g' /usr/local/src/zabbix/frontends/php/conf/zabbix.conf.php
sed -i 's/ZS_DBPassword/'${ZS_DBPassword}'/g' /usr/local/src/zabbix/frontends/php/conf/zabbix.conf.php
sed -i 's/ZS_DBPort/'${ZS_DBPort}'/g' /usr/local/src/zabbix/frontends/php/conf/zabbix.conf.php
sed -i 's/ZS_DBName/'${ZS_DBName}'/g' /usr/local/src/zabbix/frontends/php/conf/zabbix.conf.php
sed -i 's/PHP_TIMEZONE/'${PHP_TIMEZONE}'/g' /etc/php.d/zz-zabbix.ini
}
####################### End of default settings #######################
# Zabbix default sql files
ZABBIX_SQL_DIR="/usr/local/src/zabbix/database/mysql"
log "Preparing server configuration"
update_config
log "Config updated."
log "Enabling Logging and pid management."
logging
system_pids
fix_permissions
log "Done"
log "Checking if Database exists or fresh install"
if ! mysql -u ${DB_USER} -p${DB_PASS} -h ${DB_ADDRESS} -e "use zabbix;"; then
warning "Zabbix DB doesn't exists. Installing and importing default settings"
log `create_db`
log "Database and user created. Importing Default SQL"
log `import_zabbix_db`
log "Import Finished. Starting"
else
log "Zabbix DB Exists. Starting server."
fi
# TODO wait for zabbix-server start
#python /config/pyzabbix.py 2>/dev/null
zabbix_agentd -c /usr/local/etc/zabbix_agentd.conf

Просмотреть файл

@ -0,0 +1,6 @@
from zabbix.api import ZabbixAPI
zapi = ZabbixAPI(url='http://localhost/', user='Admin', password='zabbix')
hosts = zapi.host.getobjects(status=1)
for host in hosts:
print 'Enabling host: %s' % host['name']
zapi.host.update(hostid=host['hostid'],status=0)

Просмотреть файл

@ -0,0 +1,12 @@
server {
listen 80 default;
root /usr/local/src/zabbix/frontends/php;
index index.php index.html;
include /etc/nginx/conf.d/default-*.conf;
include /data/conf/nginx/conf.d/default-*.conf;
# PHP backend is not in the default-*.conf file set,
# as some vhost might not want to include it.
include /etc/nginx/conf.d/php-location.conf;
}

Просмотреть файл

@ -0,0 +1,3 @@
date.timezone = PHP_TIMEZONE
max_execution_time = 300
max_input_time = 300

Просмотреть файл

@ -0,0 +1,4 @@
# Zabbix Sudoer configuration required to provide OS Discovery through `nmap`
zabbix ALL=(ALL) NOPASSWD:ALL
Defaults!/usr/bin/nmap !requiretty
Defaults:zabbix !requiretty

Просмотреть файл

@ -0,0 +1,7 @@
[program:zabbix-server]
command = /config/ds.sh /var/run/zabbix_server.pid zabbix_server -c /usr/local/etc/zabbix_server.conf
autorestart = true
#[program:zabbix-agent]
#command = /config/ds.sh /var/run/zabbix_agentd.pid zabbix_agentd -c /usr/local/etc/zabbix_agentd.conf
#autorestart = true

Просмотреть файл

@ -0,0 +1,20 @@
<?php
// Zabbix GUI configuration file
global $DB;
$DB['TYPE'] = 'MYSQL';
$DB['SERVER'] = 'ZS_DBHost';
$DB['PORT'] = 'ZS_DBPort';
$DB['DATABASE'] = 'ZS_DBName';
$DB['USER'] = 'ZS_DBUser';
$DB['PASSWORD'] = 'ZS_DBPassword';
// SCHEMA is relevant only for IBM_DB2 database
$DB['SCHEMA'] = '';
$ZBX_SERVER = 'localhost';
$ZBX_SERVER_PORT = '10051';
$ZBX_SERVER_NAME = 'Zabbix Server';
$IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;
?>

Просмотреть файл

@ -0,0 +1,12 @@
PidFile=/var/run/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=1
DebugLevel=3
Server=127.0.0.1
ListenIP=127.0.0.1
StartAgents=1
ServerActive=127.0.0.1
Hostname=Zabbix server
RefreshActiveChecks=60
BufferSend=1
Include=/usr/local/etc/zabbix_agentd.conf.d/

Просмотреть файл

@ -0,0 +1,2 @@
LISTEN_IP="0.0.0.0"
PID_FILE="/var/run/zabbix_java.pid"

Просмотреть файл

@ -0,0 +1,632 @@
# This is a configuration file for Zabbix Server process
# To get more information about Zabbix,
# visit http://www.zabbix.com
############ GENERAL PARAMETERS #################
### Option: ListenPort
# Listen port for trapper.
#
# Mandatory: no
# Range: 1024-32767
# Default:
# ListenPort=10051
ListenPort=ZS_ListenPort
### Option: SourceIP
# Source IP address for outgoing connections.
#
# Mandatory: no
# Default:
# SourceIP=
SourceIP=ZS_SourceIP
### Option: LogFile
# Name of log file.
# If not set, syslog is used.
#
# Mandatory: no
# Default:
# LogFile=
LogFile=ZS_LogFile
### Option: LogFileSize
# Maximum size of log file in MB.
# 0 - disable automatic log rotation.
#
# Mandatory: no
# Range: 0-1024
# Default:
# LogFileSize=1
LogFileSize=ZS_LogFileSize
### Option: DebugLevel
# Specifies debug level
# 0 - basic information about starting and stopping of Zabbix processes
# 1 - critical information
# 2 - error information
# 3 - warnings
# 4 - for debugging (produces lots of information)
#
# Mandatory: no
# Range: 0-4
# Default:
# DebugLevel=3
DebugLevel=ZS_DebugLevel
### Option: PidFile
# Name of PID file.
#
# Mandatory: no
# Default:
# PidFile=/tmp/zabbix_server.pid
PidFile=ZS_PidFile
### Option: DBHost
# Database host name.
# If set to localhost, socket is used for MySQL.
# If set to empty string, socket is used for PostgreSQL.
#
# Mandatory: no
# Default:
# DBHost=localhost
DBHost=ZS_DBHost
### Option: DBName
# Database name.
# For SQLite3 path to database file must be provided. DBUser and DBPassword are ignored.
#
# Mandatory: yes
# Default:
# DBName=
DBName=ZS_DBName
### Option: DBSchema
# Schema name. Used for IBM DB2 and PostgreSQL.
#
# Mandatory: no
# Default:
# DBSchema=
DBSchema=ZS_DBSchema
### Option: DBUser
# Database user. Ignored for SQLite.
#
# Mandatory: no
# Default:
# DBUser=
DBUser=ZS_DBUser
### Option: DBPassword
# Database password. Ignored for SQLite.
# Comment this line if no password is used.
#
# Mandatory: no
# Default:
# DBPassword=
DBPassword=ZS_DBPassword
### Option: DBSocket
# Path to MySQL socket.
#
# Mandatory: no
# Default:
# DBSocket=/tmp/mysql.sock
DBSocket=ZS_DBSocket
### Option: DBPort
# Database port when not using local socket. Ignored for SQLite.
#
# Mandatory: no
# Range: 1024-65535
# Default (for MySQL):
# DBPort=3306
DBPort=ZS_DBPort
############ ADVANCED PARAMETERS ################
### Option: StartPollers
# Number of pre-forked instances of pollers.
#
# Mandatory: no
# Range: 0-1000
# Default:
# StartPollers=5
StartPollers=ZS_StartPollers
### Option: StartIPMIPollers
# Number of pre-forked instances of IPMI pollers.
#
# Mandatory: no
# Range: 0-1000
# Default:
# StartIPMIPollers=0
### Option: StartPollersUnreachable
# Number of pre-forked instances of pollers for unreachable hosts (including IPMI and Java).
# At least one poller for unreachable hosts must be running if regular, IPMI or Java pollers
# are started.
#
# Mandatory: no
# Range: 0-1000
# Default:
# StartPollersUnreachable=1
StartPollersUnreachable=ZS_StartPollersUnreachable
### Option: StartTrappers
# Number of pre-forked instances of trappers.
# Trappers accept incoming connections from Zabbix sender, active agents and active proxies.
# At least one trapper process must be running to display server availability and view queue
# in the frontend.
#
# Mandatory: no
# Range: 0-1000
# Default:
# StartTrappers=5
StartTrappers=ZS_StartTrappers
### Option: StartPingers
# Number of pre-forked instances of ICMP pingers.
#
# Mandatory: no
# Range: 0-1000
# Default:
# StartPingers=1
StartPingers=ZS_StartPingers
### Option: StartDiscoverers
# Number of pre-forked instances of discoverers.
#
# Mandatory: no
# Range: 0-250
# Default:
# StartDiscoverers=1
StartDiscoverers=ZS_StartDiscoverers
### Option: StartHTTPPollers
# Number of pre-forked instances of HTTP pollers.
#
# Mandatory: no
# Range: 0-1000
# Default:
# StartHTTPPollers=1
StartHTTPPollers=ZS_StartHTTPPollers
### Option: StartTimers
# Number of pre-forked instances of timers.
# Timers process time-based trigger functions and maintenance periods.
# Only the first timer process handles the maintenance periods.
#
# Mandatory: no
# Range: 1-1000
# Default:
# StartTimers=1
StartTimers=ZS_StartTimers
### Option: JavaGateway
# IP address (or hostname) of Zabbix Java gateway.
# Only required if Java pollers are started.
#
# Mandatory: no
# Default:
# JavaGateway=
JavaGateway=ZS_JavaGateway
### Option: JavaGatewayPort
# Port that Zabbix Java gateway listens on.
#
# Mandatory: no
# Range: 1024-32767
# Default:
# JavaGatewayPort=10052
JavaGatewayPort=ZS_JavaGatewayPort
### Option: StartJavaPollers
# Number of pre-forked instances of Java pollers.
#
# Mandatory: no
# Range: 0-1000
# Default:
# StartJavaPollers=0
StartJavaPollers=ZS_StartJavaPollers
### Option: StartVMwareCollectors
# Number of pre-forked vmware collector instances.
#
# Mandatory: no
# Range: 0-250
# Default:
# StartVMwareCollectors=0
StartVMwareCollectors=ZS_StartVMwareCollectors
### Option: VMwareFrequency
# How often Zabbix will connect to VMware service to obtain a new data.
#
# Mandatory: no
# Range: 10-86400
# Default:
# VMwareFrequency=60
VMwareFrequency=ZS_VMwareFrequency
### Option: VMwarePerfFrequency
# How often Zabbix will connect to VMware service to obtain performance data.
#
# Mandatory: no
# Range: 10-86400
# Default:
# VMwarePerfFrequency=60
VMwarePerfFrequency=ZS_VMwarePerfFrequency
### Option: VMwareCacheSize
# Size of VMware cache, in bytes.
# Shared memory size for storing VMware data.
# Only used if VMware collectors are started.
#
# Mandatory: no
# Range: 256K-2G
# Default:
# VMwareCacheSize=8M
VMwareCacheSize=ZS_VMwareCacheSize
### Option: VMwareTimeout
# Specifies how many seconds vmware collector waits for response from VMware service.
#
# Mandatory: no
# Range: 1-300
# Default:
# VMwareTimeout=10
VMwareTimeout=ZS_VMwareTimeout
### Option: SNMPTrapperFile
# Temporary file used for passing data from SNMP trap daemon to the server.
# Must be the same as in zabbix_trap_receiver.pl or SNMPTT configuration file.
#
# Mandatory: no
# Default:
# SNMPTrapperFile=/tmp/zabbix_traps.tmp
SNMPTrapperFile=ZS_SNMPTrapperFile
### Option: StartSNMPTrapper
# If 1, SNMP trapper process is started.
#
# Mandatory: no
# Range: 0-1
# Default:
# StartSNMPTrapper=0
StartSNMPTrapper=ZS_StartSNMPTrapper
### Option: ListenIP
# List of comma delimited IP addresses that the trapper should listen on.
# Trapper will listen on all network interfaces if this parameter is missing.
#
# Mandatory: no
# Default:
# ListenIP=0.0.0.0
ListenIP=ZS_ListenIP
### Option: HousekeepingFrequency
# How often Zabbix will perform housekeeping procedure (in hours).
# Housekeeping is removing outdated information from the database.
# To prevent Housekeeper from being overloaded, no more than 4 times HousekeepingFrequency
# hours of outdated information are deleted in one housekeeping cycle, for each item.
# To lower load on server startup housekeeping is postponed for 30 minutes after server start.
#
# Mandatory: no
# Range: 1-24
# Default:
# HousekeepingFrequency=1
HousekeepingFrequency=ZS_HousekeepingFrequency
### Option: MaxHousekeeperDelete
# The table "housekeeper" contains "tasks" for housekeeping procedure in the format:
# [housekeeperid], [tablename], [field], [value].
# No more than 'MaxHousekeeperDelete' rows (corresponding to [tablename], [field], [value])
# will be deleted per one task in one housekeeping cycle.
# SQLite3 does not use this parameter, deletes all corresponding rows without a limit.
# If set to 0 then no limit is used at all. In this case you must know what you are doing!
#
# Mandatory: no
# Range: 0-1000000
# Default:
# MaxHousekeeperDelete=500
MaxHousekeeperDelete=ZS_MaxHousekeeperDelete
### Option: SenderFrequency
# How often Zabbix will try to send unsent alerts (in seconds).
#
# Mandatory: no
# Range: 5-3600
# Default:
# SenderFrequency=30
SenderFrequency=ZS_SenderFrequency
### Option: CacheSize
# Size of configuration cache, in bytes.
# Shared memory size for storing host, item and trigger data.
#
# Mandatory: no
# Range: 128K-8G
# Default:
# CacheSize=8M
CacheSize=ZS_CacheSize
### Option: CacheUpdateFrequency
# How often Zabbix will perform update of configuration cache, in seconds.
#
# Mandatory: no
# Range: 1-3600
# Default:
# CacheUpdateFrequency=60
CacheUpdateFrequency=ZS_CacheUpdateFrequency
### Option: StartDBSyncers
# Number of pre-forked instances of DB Syncers
#
# Mandatory: no
# Range: 1-100
# Default:
# StartDBSyncers=4
StartDBSyncers=ZS_StartDBSyncers
### Option: HistoryCacheSize
# Size of history cache, in bytes.
# Shared memory size for storing history data.
#
# Mandatory: no
# Range: 128K-2G
# Default:
# HistoryCacheSize=8M
HistoryCacheSize=ZS_HistoryCacheSize
### Option: TrendCacheSize
# Size of trend cache, in bytes.
# Shared memory size for storing trends data.
#
# Mandatory: no
# Range: 128K-2G
# Default:
# TrendCacheSize=4M
TrendCacheSize=ZS_TrendCacheSize
### Option: HistoryTextCacheSize
# Size of text history cache, in bytes.
# Shared memory size for storing character, text or log history data.
#
# Mandatory: no
# Range: 128K-2G
# Default:
# HistoryTextCacheSize=16M
HistoryTextCacheSize=ZS_HistoryTextCacheSize
### Option: ValueCacheSize
# Size of history value cache, in bytes.
# Shared memory size for caching item history data requests.
# Setting to 0 disables value cache.
#
# Mandatory: no
# Range: 0,128K-64G
# Default:
# ValueCacheSize=8M
ValueCacheSize=ZS_ValueCacheSize
### Option: Timeout
# Specifies how long we wait for agent, SNMP device or external check (in seconds).
#
# Mandatory: no
# Range: 1-30
# Default:
# Timeout=3
Timeout=ZS_Timeout
### Option: TrapperTimeout
# Specifies how many seconds trapper may spend processing new data.
#
# Mandatory: no
# Range: 1-300
# Default:
# TrapperTimeout=300
TrapperTimeout=ZS_TrapperTimeout
### Option: UnreachablePeriod
# After how many seconds of unreachability treat a host as unavailable.
#
# Mandatory: no
# Range: 1-3600
# Default:
# UnreachablePeriod=45
UnreachablePeriod=ZS_UnreachablePeriod
### Option: UnavailableDelay
# How often host is checked for availability during the unavailability period, in seconds.
#
# Mandatory: no
# Range: 1-3600
# Default:
# UnavailableDelay=60
UnavailableDelay=ZS_UnavailableDelay
### Option: UnreachableDelay
# How often host is checked for availability during the unreachability period, in seconds.
#
# Mandatory: no
# Range: 1-3600
# Default:
# UnreachableDelay=15
UnreachableDelay=ZS_UnreachableDelay
### Option: AlertScriptsPath
# Full path to location of custom alert scripts.
# Default depends on compilation options.
#
# Mandatory: no
# Default:
# AlertScriptsPath=${datadir}/zabbix/alertscripts
AlertScriptsPath=ZS_AlertScriptsPath
### Option: ExternalScripts
# Full path to location of external scripts.
# Default depends on compilation options.
#
# Mandatory: no
# Default:
# ExternalScripts=${datadir}/zabbix/externalscripts
ExternalScripts=ZS_ExternalScripts
### Option: FpingLocation
# Location of fping.
# Make sure that fping binary has root ownership and SUID flag set.
#
# Mandatory: no
# Default:
# FpingLocation=/usr/sbin/fping
FpingLocation=ZS_FpingLocation
### Option: Fping6Location
# Location of fping6.
# Make sure that fping6 binary has root ownership and SUID flag set.
# Make empty if your fping utility is capable to process IPv6 addresses.
#
# Mandatory: no
# Default:
# Fping6Location=/usr/sbin/fping6
Fping6Location=ZS_Fping6Location
### Option: SSHKeyLocation
# Location of public and private keys for SSH checks and actions.
#
# Mandatory: no
# Default:
# SSHKeyLocation=
SSHKeyLocation=ZS_SSHKeyLocation
### Option: LogSlowQueries
# How long a database query may take before being logged (in milliseconds).
# Only works if DebugLevel set to 3 or 4.
# 0 - don't log slow queries.
#
# Mandatory: no
# Range: 1-3600000
# Default:
# LogSlowQueries=0
LogSlowQueries=ZS_LogSlowQueries
### Option: TmpDir
# Temporary directory.
#
# Mandatory: no
# Default:
# TmpDir=/tmp
TmpDir=ZS_TmpDir
### Option: StartProxyPollers
# Number of pre-forked instances of pollers for passive proxies.
#
# Mandatory: no
# Range: 0-250
# Default:
# StartProxyPollers=1
StartProxyPollers=ZS_StartProxyPollers
### Option: ProxyConfigFrequency
# How often Zabbix Server sends configuration data to a Zabbix Proxy in seconds.
# This parameter is used only for proxies in the passive mode.
#
# Mandatory: no
# Range: 1-3600*24*7
# Default:
# ProxyConfigFrequency=3600
ProxyConfigFrequency=ZS_ProxyConfigFrequency
### Option: ProxyDataFrequency
# How often Zabbix Server requests history data from a Zabbix Proxy in seconds.
# This parameter is used only for proxies in the passive mode.
#
# Mandatory: no
# Range: 1-3600
# Default:
# ProxyDataFrequency=1
ProxyDataFrequency=ZS_ProxyDataFrequency
### Option: AllowRoot
# Allow the server to run as 'root'. If disabled and the server is started by 'root', the server
# will try to switch to the user specified by the User configuration option instead.
# Has no effect if started under a regular user.
# 0 - do not allow
# 1 - allow
#
# Mandatory: no
# Default:
# AllowRoot=0
AllowRoot=ZS_AllowRoot
### Option: User
# Drop privileges to a specific, existing user on the system.
# Only has effect if run as 'root' and AllowRoot is disabled.
#
# Mandatory: no
# Default:
# User=zabbix
User=ZS_User
### Option: Include
# You may include individual files or all files in a directory in the configuration file.
# Installing Zabbix will create include directory in /usr/local/etc, unless modified during the compile time.
#
# Mandatory: no
# Default:
# Include=
# Include=/usr/local/etc/zabbix_server.general.conf
# Include=/usr/local/etc/zabbix_server.conf.d/
# Include=/usr/local/etc/zabbix_server.conf.d/*.conf
Include=ZS_Include
### Option: SSLCertLocation
# Location of SSL client certificates.
# This parameter is used only in web monitoring.
#
# Mandatory: no
# Default:
# SSLCertLocation=${datadir}/zabbix/ssl/certs
SSLCertLocation=ZS_SSLCertLocation
### Option: SSLKeyLocation
# Location of private keys for SSL client certificates.
# This parameter is used only in web monitoring.
#
# Mandatory: no
# Default:
# SSLKeyLocation=${datadir}/zabbix/ssl/keys
SSLKeyLocation=ZS_SSLKeyLocation
### Option: SSLCALocation
# Override the location of certificate authority (CA) files for SSL server certificate verification.
# If not set, system-wide directory will be used.
# This parameter is used only in web monitoring.
#
# Mandatory: no
# Default:
# SSLCALocation=
SSLCALocation=ZS_SSLCALocation
####### LOADABLE MODULES #######
### Option: LoadModulePath
# Full path to location of server modules.
# Default depends on compilation options.
#
# Mandatory: no
# Default:
# LoadModulePath=${libdir}/modules
LoadModulePath=ZS_LoadModulePath
### Option: LoadModule
# Module to load at server startup. Modules are used to extend functionality of the server.
# Format: LoadModule=<module.so>
# The modules must be located in directory specified by LoadModulePath.
# It is allowed to include multiple LoadModule parameters.
#
# Mandatory: no
# Default:
# LoadModule=
LoadModule=ZS_LoadModule