├── .gitignore ├── doc └── schema.png ├── elk └── logstash │ ├── patterns │ ├── nginx.conf │ ├── symfony.conf │ └── default.conf │ └── logstash.conf ├── .env.dist ├── .travis.yml ├── nginx ├── symfony.conf ├── nginx.conf └── Dockerfile ├── LICENSE ├── php7-fpm └── Dockerfile ├── docker-compose.yml └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | /logs 2 | /.data 3 | .env 4 | -------------------------------------------------------------------------------- /doc/schema.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/carlosas/docker-for-symfony/HEAD/doc/schema.png -------------------------------------------------------------------------------- /elk/logstash/patterns/nginx.conf: -------------------------------------------------------------------------------- 1 | NGINXACCESS %{IPORHOST:clientip} %{USER:ident} %{USER:auth} \[%{HTTPDATE:timestamp}\] "(?:%{WORD:verb} %{URIPATHPARAM:request}(?: HTTP/%{NUMBER:httpversion})?|-)" %{NUMBER:response} (?:%{NUMBER:bytes}|-) "(?:%{URI:referrer}|-)" %{QS:agent} %{NUMBER:request_time} %{NUMBER:upstream_response_time} %{NUMBER:gzip_ratio} (?:%{WORD:cache_hit}|-)%{GREEDYDATA} -------------------------------------------------------------------------------- /.env.dist: -------------------------------------------------------------------------------- 1 | # Symfony application's path (absolute or relative) 2 | SYMFONY_APP_PATH=../path/to/symfony/folder 3 | 4 | # PHP/nginx 5 | SERVER_NAME=symfony.dev 6 | TIMEZONE=Europe/Madrid 7 | MAX_EXECUTION_TIME=60 8 | 9 | # MySQL 10 | MYSQL_ROOT_PASSWORD=root 11 | MYSQL_DATABASE=db_name 12 | MYSQL_USER=db_user 13 | MYSQL_PASSWORD=db_password 14 | 15 | # RabbitMQ 16 | RABBITMQ_USER=rabbit 17 | RABBITMQ_PASSWORD=mq 18 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: required 2 | 3 | env: 4 | DOCKER_COMPOSE_VERSION: 1.18.0 5 | 6 | services: 7 | - docker 8 | 9 | before_install: 10 | - sudo service mysql stop 11 | - curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose 12 | - chmod +x docker-compose 13 | - sudo mv docker-compose /usr/local/bin 14 | - mkdir symfony 15 | - cp .env.dist .env 16 | 17 | script: 18 | - docker-compose build 19 | - docker-compose up -d 20 | - docker-compose ps 21 | 22 | notifications: 23 | email: 24 | on_success: never 25 | on_failure: always 26 | -------------------------------------------------------------------------------- /nginx/symfony.conf: -------------------------------------------------------------------------------- 1 | server { 2 | server_name symfony.dev; 3 | root /var/www/symfony/public; 4 | 5 | location / { 6 | try_files $uri @rewriteapp; 7 | } 8 | 9 | location @rewriteapp { 10 | rewrite ^(.*)$ /index.php/$1 last; 11 | } 12 | 13 | location ~ ^/(index)\.php(/|$) { 14 | fastcgi_pass php-upstream; 15 | fastcgi_split_path_info ^(.+\.php)(/.*)$; 16 | include fastcgi_params; 17 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 18 | fastcgi_param HTTPS off; 19 | } 20 | 21 | error_log /var/log/nginx/symfony_error.log; 22 | access_log /var/log/nginx/symfony_access.log; 23 | } 24 | -------------------------------------------------------------------------------- /nginx/nginx.conf: -------------------------------------------------------------------------------- 1 | user www-data; 2 | worker_processes 4; 3 | pid /run/nginx.pid; 4 | 5 | events { 6 | worker_connections 2048; 7 | multi_accept on; 8 | use epoll; 9 | } 10 | 11 | http { 12 | server_tokens off; 13 | sendfile on; 14 | tcp_nopush on; 15 | tcp_nodelay on; 16 | keepalive_timeout 15; 17 | types_hash_max_size 2048; 18 | include /etc/nginx/mime.types; 19 | default_type application/octet-stream; 20 | access_log off; 21 | error_log off; 22 | gzip on; 23 | gzip_disable "msie6"; 24 | include /etc/nginx/conf.d/*.conf; 25 | include /etc/nginx/sites-enabled/*; 26 | open_file_cache max=100; 27 | fastcgi_read_timeout 60s; 28 | } 29 | 30 | daemon off; 31 | -------------------------------------------------------------------------------- /nginx/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM debian:jessie 2 | ARG MAX_EXECUTION_TIME 3 | ARG SERVER_NAME 4 | 5 | # Install nginx 6 | RUN apt-get update && apt-get install -y nginx 7 | 8 | # Configure Nginx 9 | ADD nginx.conf /etc/nginx/ 10 | RUN sed "/fastcgi_read_timeout 60s;/c\ fastcgi_read_timeout ${MAX_EXECUTION_TIME}s;" -i /etc/nginx/nginx.conf 11 | ADD symfony.conf /etc/nginx/sites-available/ 12 | RUN sed "/server_name symfony.dev;/c\ server_name ${SERVER_NAME};" -i /etc/nginx/sites-available/symfony.conf 13 | RUN echo "upstream php-upstream { server php:9000; }" > /etc/nginx/conf.d/upstream.conf 14 | RUN usermod -u 1000 www-data 15 | 16 | # Configure the virtual host 17 | RUN ln -s /etc/nginx/sites-available/symfony.conf /etc/nginx/sites-enabled/symfony 18 | RUN rm /etc/nginx/sites-enabled/default 19 | 20 | # Run Nginx 21 | CMD ["nginx"] 22 | 23 | # Expose ports 24 | EXPOSE 80 25 | EXPOSE 443 26 | -------------------------------------------------------------------------------- /elk/logstash/logstash.conf: -------------------------------------------------------------------------------- 1 | input { 2 | file { 3 | type => "nginx_access" 4 | path => "/var/log/nginx/symfony_access.log" 5 | start_position => beginning 6 | } 7 | file { 8 | type => "symfony_dev" 9 | path => "/var/www/symfony/var/log/dev.log" 10 | start_position => beginning 11 | } 12 | file { 13 | type => "symfony_prod" 14 | path => "/var/www/symfony/var/log/prod.log" 15 | start_position => beginning 16 | } 17 | lumberjack { 18 | port => 5043 19 | ssl_certificate => "/etc/ssl/logstash-forwarder.crt" 20 | ssl_key => "/etc/ssl/logstash-forwarder.key" 21 | } 22 | } 23 | 24 | filter { 25 | if [type] == "nginx_access" { 26 | grok { 27 | patterns_dir => "./patterns" 28 | match => { "message" => "%{NGINXACCESS}"} 29 | } 30 | } 31 | else if [type] in ["symfony_dev", "symfony_prod"] { 32 | grok { 33 | patterns_dir => "./patterns" 34 | match => { "message" => "%{SYMFONY}"} 35 | } 36 | } 37 | } 38 | 39 | output { 40 | elasticsearch { 41 | host => "localhost" 42 | cluster => "logstash" 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017-2019 Carlos Alandete Sastre 4 | Copyright (c) 2016 Maxence POUTORD 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | -------------------------------------------------------------------------------- /php7-fpm/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:7.2-fpm 2 | ARG TIMEZONE 3 | 4 | RUN apt-get update && apt-get install -y git unzip openssl procps acl zlib1g-dev 5 | 6 | # Install Composer 7 | RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer 8 | RUN composer --version 9 | 10 | # Set timezone 11 | RUN ln -snf /usr/share/zoneinfo/${TIMEZONE} /etc/localtime && echo ${TIMEZONE} > /etc/timezone 12 | RUN printf '[PHP]\ndate.timezone = "%s"\n', ${TIMEZONE} > /usr/local/etc/php/conf.d/tzone.ini 13 | 14 | # Install extensions 15 | RUN docker-php-ext-install pdo pdo_mysql bcmath zip 16 | 17 | # Install Redis extension 18 | RUN pecl install -o -f redis && rm -rf /tmp/pear && docker-php-ext-enable redis 19 | 20 | # Install xdebug 21 | RUN pecl install xdebug 22 | RUN docker-php-ext-enable xdebug 23 | RUN echo "error_reporting = E_ALL" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini 24 | RUN echo "display_startup_errors = On" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini 25 | RUN echo "display_errors = On" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini 26 | RUN echo "xdebug.remote_enable=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini 27 | RUN echo "xdebug.remote_connect_back=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini 28 | RUN echo "xdebug.idekey=\"PHPSTORM\"" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini 29 | RUN echo "xdebug.remote_port=9001" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini 30 | 31 | # Create an alias for Symfony3 console 32 | RUN echo 'alias symfony="php bin/console"' >> ~/.bashrc 33 | 34 | WORKDIR /var/www/symfony 35 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | 3 | services: 4 | redis: 5 | container_name: container_redis 6 | image: redis:alpine 7 | ports: 8 | - "6379:6379" 9 | php: 10 | container_name: container_php 11 | build: 12 | context: php7-fpm 13 | args: 14 | TIMEZONE: ${TIMEZONE} 15 | volumes: 16 | - ${SYMFONY_APP_PATH}:/var/www/symfony 17 | - ./logs/symfony:/var/www/symfony/var/log 18 | links: 19 | - redis 20 | nginx: 21 | container_name: container_nginx 22 | build: 23 | context: nginx 24 | args: 25 | MAX_EXECUTION_TIME: ${MAX_EXECUTION_TIME} 26 | SERVER_NAME: ${SERVER_NAME} 27 | ports: 28 | - "80:80" 29 | volumes_from: 30 | - php 31 | volumes: 32 | - ./logs/nginx/:/var/log/nginx 33 | mysql: 34 | container_name: container_mysql 35 | image: mysql 36 | volumes: 37 | - "./.data/mysql:/var/lib/mysql" 38 | environment: 39 | MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD} 40 | MYSQL_DATABASE: ${MYSQL_DATABASE} 41 | MYSQL_USER: ${MYSQL_USER} 42 | MYSQL_PASSWORD: ${MYSQL_PASSWORD} 43 | ports: 44 | - "3306:3306" 45 | rabbit: 46 | container_name: container_rabbit 47 | hostname: rabbit 48 | image: rabbitmq:3-management 49 | environment: 50 | RABBITMQ_DEFAULT_USER: ${RABBITMQ_USER} 51 | RABBITMQ_DEFAULT_PASS: ${RABBITMQ_PASSWORD} 52 | volumes: 53 | - ./.data/rabbitmq/:/var/lib/rabbitmq 54 | ports: 55 | - "5672:5672" 56 | - "15672:15672" 57 | elk: 58 | container_name: container_elk 59 | image: sebp/elk 60 | volumes: 61 | - ./elk/logstash:/etc/logstash 62 | - ./elk/logstash/patterns:/opt/logstash/patterns 63 | - ./.data/elasticsearch:/var/lib/elasticsearch 64 | # - ./elk/elasticsearch:/etc/elasticsearch # to place elastisearch.yml configuration 65 | volumes_from: 66 | - php 67 | - nginx 68 | ports: 69 | - "5601:5601" 70 | - "9200:9200" 71 | - "5044:5044" 72 | -------------------------------------------------------------------------------- /elk/logstash/patterns/symfony.conf: -------------------------------------------------------------------------------- 1 | VERYGREEDYDATA (.|\n)* 2 | 3 | SYMFONY_EXCEPTION [^:]* 4 | 5 | SYMFONY_LOG_TYPE request|security|app|profiler|doctrine|event 6 | SYMFONY_LOG_LEVEL DEBUG|INFO|WARNING|ERROR|CRITICAL|ALERT 7 | SYMFONY_LOG %{SYMFONY_LOG_TYPE:log_type}\.%{SYMFONY_LOG_LEVEL:log_level} 8 | 9 | SYMFONY_PARAMETER "[^"]*":( )?"[^"]*" 10 | SYMFONY_PARAMETERS (%{SYMFONY_PARAMETER}(, )?)* 11 | SYMFONY_CONTEXT {.*} 12 | SYMFONY_REQUEST_METHOD GET|POST|PUT|DELETE|HEAD|OPTIONS|CONNECT 13 | SYMFONY_REQUEST_PARAMETERS {"url":"%{GREEDYDATA:request_url}","ip":"%{IP:request_ip}","http_method":"%{SYMFONY_REQUEST_METHOD:request_method}"} 14 | 15 | SYMFONY_REQUEST_INFO Matched route "%{GREEDYDATA:route}" \(parameters: %{SYMFONY_PARAMETERS:parameters}\) 16 | SYMFONY_REQUEST_UNCAUGHT_EXCEPTION %{SYMFONY_EXCEPTION:exception}: %{VERYGREEDYDATA:exception_message} \(uncaught exception\) at %{VERYGREEDYDATA:exception_file} line %{NUMBER:exception_file_line} 17 | SYMFONY_REQUEST_CRITICAL Exception thrown when handling an exception \(ErrorException: %{GREEDYDATA:exception_message} in %{GREEDYDATA:exception_file} line %{NUMBER:exception_file_line}\) 18 | SYMFONY_SECURITY_WARNING_USER_MISSING Username "%{GREEDYDATA:user}" could not be found. 19 | SYMFONY_SECURITY_INFO_USER_AUTHENTICATED User "%{GREEDYDATA:user}" has been authenticated successfully 20 | SYMFONY_SECURITY_INFO_AUTHENTICATION_FAILED Authentication request failed: %{GREEDYDATA:authentication_fail_reason} 21 | SYMFONY_SECURITY_DEBUG Username "%{GREEDYDATA:user}" was reloaded from user provider. 22 | SYMFONY_EVENT_DEBUG_NOTIFICATION Notified event "%{GREEDYDATA:event}" to listener "%{GREEDYDATA:listener}". 23 | SYMFONY_EVENT_DEBUG_PROPAGATION_STOP Listener "%{GREEDYDATA:listener}" stopped propagation of the event "%{GREEDYDATA:event}". 24 | SYMFONY_DOCTRINE_DEBUG (?<=doctrine.DEBUG: ).* 25 | 26 | SYMFONY_REQUEST %{SYMFONY_REQUEST_INFO}|%{SYMFONY_REQUEST_UNCAUGHT_EXCEPTION}|%{SYMFONY_REQUEST_CRITICAL} 27 | SYMFONY_SECURITY %{SYMFONY_SECURITY_WARNING_USER_MISSING}|%{SYMFONY_SECURITY_INFO_USER_AUTHENTICATED}|%{SYMFONY_SECURITY_DEBUG}|%{SYMFONY_SECURITY_INFO_AUTHENTICATION_FAILED} 28 | SYMFONY_EVENT %{SYMFONY_EVENT_DEBUG_NOTIFICATION}|%{SYMFONY_EVENT_DEBUG_PROPAGATION_STOP} 29 | SYMFONY_DOCTRINE %{SYMFONY_DOCTRINE_DEBUG:doctrine_sql_query} 30 | SYMFONY_VARIOUS_INFO Write SecurityContext in the session|Reloading user from user provider.|Read SecurityContext from the session|Populated SecurityContext with an anonymous Token|Access is denied (and user is neither anonymous, nor remember-me)|Unable to store the profiler information.|Remember-me cookie accepted. 31 | 32 | SYMFONY_LOG_MESSAGE %{SYMFONY_REQUEST}|%{SYMFONY_SECURITY}|%{SYMFONY_EVENT}|%{SYMFONY_DOCTRINE}|%{SYMFONY_VARIOUS_INFO:log_various_info}|%{VERYGREEDYDATA:log_unparsed_message} 33 | 34 | SYMFONY ^\[%{TIMESTAMP_ISO8601:date}\] %{SYMFONY_LOG}: %{SYMFONY_LOG_MESSAGE:log_message} (\[\]|%{SYMFONY_CONTEXT:log_context}) (\[\]|%{SYMFONY_REQUEST_PARAMETERS:log_request}) -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Docker stack for Symfony projects 2 | 3 | [![Build Status](https://travis-ci.org/carlosas/docker-for-symfony.svg?branch=master)](https://travis-ci.org/carlosas/docker-for-symfony) 4 | :octocat: 5 | [![license](https://img.shields.io/github/license/mashape/apistatus.svg?style=flat-square)](LICENSE) 6 | [![contributions](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat-square)](https://github.com/carlosas/docker-for-symfony/issues) 7 | [![HitCount](http://hits.dwyl.com/carlosas/docker-for-symfony.svg)](http://hits.dwyl.com/carlosas/docker-for-symfony) 8 | 9 | ![](doc/schema.png) 10 | 11 | ## Basic info 12 | 13 | * [nginx](https://nginx.org/) 14 | * [PHP-FPM](https://php-fpm.org/) 15 | * [MySQL](https://www.mysql.com/) 16 | * [Redis](https://redis.io/) 17 | * [Elasticsearch](https://www.elastic.co/products/elasticsearch) 18 | * [Logstash](https://www.elastic.co/products/logstash) 19 | * [Kibana](https://www.elastic.co/products/kibana) 20 | * [RabbitMQ](https://www.rabbitmq.com/) 21 | 22 | ## Previous requirements 23 | 24 | This stack needs [docker](https://www.docker.com/) and [docker-compose](https://docs.docker.com/compose/) to be installed. 25 | 26 | ## Installation 27 | 28 | 1. Create a `.env` file from `.env.dist` and adapt it according to the needs of the application 29 | 30 | ```sh 31 | $ cp .env.dist .env && nano .env 32 | ``` 33 | 34 | 2. Due to an Elasticsearch 6 requirement, we may need to set a host's sysctl option and restart ([More info](https://github.com/spujadas/elk-docker/issues/92)): 35 | 36 | ```sh 37 | $ sudo sysctl -w vm.max_map_count=262144 38 | ``` 39 | 40 | 3. Build and run the stack in detached mode (stop any system's ngixn/apache2 service first) 41 | 42 | ```sh 43 | $ docker-compose build 44 | $ docker-compose up -d 45 | ``` 46 | 47 | 4. Get the bridge IP address 48 | 49 | ```sh 50 | $ docker network inspect bridge | grep Gateway | grep -o -E '[0-9\.]+' 51 | # OR an alternative command 52 | $ ifconfig docker0 | awk '/inet:/{ print substr($2,6); exit }' 53 | ``` 54 | 55 | 5. Update your system's hosts file with the IP retrieved in **step 3** 56 | 57 | 6. Prepare the Symfony application 58 | 1. Update Symfony env variables (*.env*) 59 | 60 | ``` 61 | #... 62 | DATABASE_URL=mysql://db_user:db_password@mysql:3306/db_name 63 | #... 64 | ``` 65 | 66 | 2. Composer install & update the schema from the container 67 | 68 | ```sh 69 | $ docker-compose exec php bash 70 | $ composer install 71 | $ symfony doctrine:schema:update --force 72 | ``` 73 | 7. (Optional) Xdebug: Configure your IDE to connect to port `9001` with key `PHPSTORM` 74 | 75 | ## How does it work? 76 | 77 | We have the following *docker-compose* built images: 78 | 79 | * `nginx`: The Nginx webserver container in which the application volume is mounted. 80 | * `php`: The PHP-FPM container in which the application volume is mounted too. 81 | * `mysql`: The MySQL database container. 82 | * `elk`: Container which uses Logstash to collect logs, send them into Elasticsearch and visualize them with Kibana. 83 | * `redis`: The Redis server container. 84 | * `rabbitmq`: The RabbitMQ server/administration container. 85 | 86 | Running `docker-compose ps` should result in the following running containers: 87 | 88 | ``` 89 | Name Command State Ports 90 | -------------------------------------------------------------------------------------------------- 91 | container_mysql /entrypoint.sh mysqld Up 0.0.0.0:3306->3306/tcp 92 | container_nginx nginx Up 443/tcp, 0.0.0.0:80->80/tcp 93 | container_phpfpm php-fpm Up 0.0.0.0:9000->9000/tcp 94 | container_redis docker-entrypoint.sh redis ... Up 6379/tcp 95 | container_rabbit rabbitmq:3-management Up 4369/tcp, 5671/tcp, 0.0.0.0:5672->5672/tcp, 15671/tcp, 25672/tcp, 0.0.0.0:15672->15672 96 | container_elk /usr/bin/supervisord -n -c ... Up 0.0.0.0:5044->5044/tcp, 0.0.0.0:5601->5601/tcp, 0.0.0.0:9200->9200/tcp, 9300/tcp 97 | ``` 98 | 99 | ## Usage 100 | 101 | Once all the containers are up, our services are available at: 102 | 103 | * Symfony app: `http://symfony.dev:80` 104 | * Mysql server: `symfony.dev:3306` 105 | * Redis: `symfony.dev:6379` 106 | * Elasticsearch: `symfony.dev:9200` 107 | * Kibana: `http://symfony.dev:5601` 108 | * RabbitMQ: `http://symfony.dev:15672` 109 | * Log files location: *logs/nginx* and *logs/symfony* 110 | 111 | :tada: Now we can stop our stack with `docker-compose down` and start it again with `docker-compose up -d` 112 | 113 | --- 114 | 115 | Software based on [eko/docker-symfony](https://github.com/eko/docker-symfony) and [maxpou/docker-symfony](https://github.com/maxpou/docker-symfony) 116 | -------------------------------------------------------------------------------- /elk/logstash/patterns/default.conf: -------------------------------------------------------------------------------- 1 | USERNAME [a-zA-Z0-9._-]+ 2 | USER %{USERNAME} 3 | INT (?:[+-]?(?:[0-9]+)) 4 | BASE10NUM (?[+-]?(?:(?:[0-9]+(?:\.[0-9]+)?)|(?:\.[0-9]+))) 5 | NUMBER (?:%{BASE10NUM}) 6 | BASE16NUM (?(?"(?>\\.|[^\\"]+)+"|""|(?>'(?>\\.|[^\\']+)+')|''|(?>`(?>\\.|[^\\`]+)+`)|``)) 17 | UUID [A-Fa-f0-9]{8}-(?:[A-Fa-f0-9]{4}-){3}[A-Fa-f0-9]{12} 18 | # Networking 19 | MAC (?:%{CISCOMAC}|%{WINDOWSMAC}|%{COMMONMAC}) 20 | CISCOMAC (?:(?:[A-Fa-f0-9]{4}\.){2}[A-Fa-f0-9]{4}) 21 | WINDOWSMAC (?:(?:[A-Fa-f0-9]{2}-){5}[A-Fa-f0-9]{2}) 22 | COMMONMAC (?:(?:[A-Fa-f0-9]{2}:){5}[A-Fa-f0-9]{2}) 23 | IPV6 ((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)? 24 | IPV4 (?/(?>[\w_%!$@:.,-]+|\\.)*)+ 33 | TTY (?:/dev/(pts|tty([pq])?)(\w+)?/?(?:[0-9]+)) 34 | WINPATH (?>[A-Za-z]+:|\\)(?:\\[^\\?*]*)+ 35 | URIPROTO [A-Za-z]+(\+[A-Za-z+]+)? 36 | URIHOST %{IPORHOST}(?::%{POSINT:port})? 37 | # uripath comes loosely from RFC1738, but mostly from what Firefox 38 | # doesn't turn into %XX 39 | URIPATH (?:/[A-Za-z0-9$.+!*'(){},~:;=@#%_\-]*)+ 40 | #URIPARAM \?(?:[A-Za-z0-9]+(?:=(?:[^&]*))?(?:&(?:[A-Za-z0-9]+(?:=(?:[^&]*))?)?)*)? 41 | URIPARAM \?[A-Za-z0-9$.+!*'|(){},~@#%&/=:;_?\-\[\]]* 42 | URIPATHPARAM %{URIPATH}(?:%{URIPARAM})? 43 | URI %{URIPROTO}://(?:%{USER}(?::[^@]*)?@)?(?:%{URIHOST})?(?:%{URIPATHPARAM})? 44 | # Months: January, Feb, 3, 03, 12, December 45 | MONTH \b(?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|Jun(?:e)?|Jul(?:y)?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\b 46 | MONTHNUM (?:0?[1-9]|1[0-2]) 47 | MONTHNUM2 (?:0[1-9]|1[0-2]) 48 | MONTHDAY (?:(?:0[1-9])|(?:[12][0-9])|(?:3[01])|[1-9]) 49 | # Days: Monday, Tue, Thu, etc... 50 | DAY (?:Mon(?:day)?|Tue(?:sday)?|Wed(?:nesday)?|Thu(?:rsday)?|Fri(?:day)?|Sat(?:urday)?|Sun(?:day)?) 51 | # Years? 52 | YEAR (?>\d\d){1,2} 53 | HOUR (?:2[0123]|[01]?[0-9]) 54 | MINUTE (?:[0-5][0-9]) 55 | # '60' is a leap second in most time standards and thus is valid. 56 | SECOND (?:(?:[0-5]?[0-9]|60)(?:[:.,][0-9]+)?) 57 | TIME (?!<[0-9])%{HOUR}:%{MINUTE}(?::%{SECOND})(?![0-9]) 58 | # datestamp is YYYY/MM/DD-HH:MM:SS.UUUU (or something like it) 59 | DATE_US %{MONTHNUM}[/-]%{MONTHDAY}[/-]%{YEAR} 60 | DATE_EU %{MONTHDAY}[./-]%{MONTHNUM}[./-]%{YEAR} 61 | ISO8601_TIMEZONE (?:Z|[+-]%{HOUR}(?::?%{MINUTE})) 62 | ISO8601_SECOND (?:%{SECOND}|60) 63 | TIMESTAMP_ISO8601 %{YEAR}-%{MONTHNUM}-%{MONTHDAY}[T ]%{HOUR}:?%{MINUTE}(?::?%{SECOND})?%{ISO8601_TIMEZONE}? 64 | DATE %{DATE_US}|%{DATE_EU} 65 | DATESTAMP %{DATE}[- ]%{TIME} 66 | TZ (?:[PMCE][SD]T|UTC) 67 | DATESTAMP_RFC822 %{DAY} %{MONTH} %{MONTHDAY} %{YEAR} %{TIME} %{TZ} 68 | DATESTAMP_RFC2822 %{DAY}, %{MONTHDAY} %{MONTH} %{YEAR} %{TIME} %{ISO8601_TIMEZONE} 69 | DATESTAMP_OTHER %{DAY} %{MONTH} %{MONTHDAY} %{TIME} %{TZ} %{YEAR} 70 | DATESTAMP_EVENTLOG %{YEAR}%{MONTHNUM2}%{MONTHDAY}%{HOUR}%{MINUTE}%{SECOND} 71 | # Syslog Dates: Month Day HH:MM:SS 72 | SYSLOGTIMESTAMP %{MONTH} +%{MONTHDAY} %{TIME} 73 | PROG (?:[\w._/%-]+) 74 | SYSLOGPROG %{PROG:program}(?:\[%{POSINT:pid}\])? 75 | SYSLOGHOST %{IPORHOST} 76 | SYSLOGFACILITY <%{NONNEGINT:facility}.%{NONNEGINT:priority}> 77 | HTTPDATE %{MONTHDAY}/%{MONTH}/%{YEAR}:%{TIME} %{INT} 78 | # Shortcuts 79 | QS %{QUOTEDSTRING} 80 | # Log formats 81 | SYSLOGBASE %{SYSLOGTIMESTAMP:timestamp} (?:%{SYSLOGFACILITY} )?%{SYSLOGHOST:logsource} %{SYSLOGPROG}: 82 | COMMONAPACHELOG %{IPORHOST:clientip} %{USER:ident} %{USER:auth} \[%{HTTPDATE:timestamp}\] "(?:%{WORD:verb} %{NOTSPACE:request}(?: HTTP/%{NUMBER:httpversion})?|%{DATA:rawrequest})" %{NUMBER:response} (?:%{NUMBER:bytes}|-) 83 | COMBINEDAPACHELOG %{COMMONAPACHELOG} %{QS:referrer} %{QS:agent} 84 | # Log Levels 85 | LOGLEVEL ([Aa]lert|ALERT|[Tt]race|TRACE|[Dd]ebug|DEBUG|[Nn]otice|NOTICE|[Ii]nfo|INFO|[Ww]arn?(?:ing)?|WARN?(?:ING)?|[Ee]rr?(?:or)?|ERR?(?:OR)?|[Cc]rit?(?:ical)?|CRIT?(?:ICAL)?|[Ff]atal|FATAL|[Ss]evere|SEVERE|EMERG(?:ENCY)?|[Ee]merg(?:ency)?) --------------------------------------------------------------------------------