From fbf5ab279bf1b707c28086dc539c7bd31d05e60a Mon Sep 17 00:00:00 2001 From: Dave Lane Date: Tue, 6 Feb 2018 17:36:10 +1300 Subject: [PATCH] working configuration --- Dockerfile | 18 +++--------------- docker-compose.yml | 18 +++++++++++++++--- nginx.conf | 47 ++++++++++++++++------------------------------ nginx/default.conf | 39 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 73 insertions(+), 49 deletions(-) create mode 100644 nginx/default.conf diff --git a/Dockerfile b/Dockerfile index 58a0cdf..cad319a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,9 @@ FROM php:7.0-fpm-jessie MAINTAINER Dave Lane (@lightweight) -#ENV PHPREDIS_VERSION 3.1.4 RUN apt-get update && apt-get install -y software-properties-common apt-utils -RUN DEBIAN_FRONTEND="noninteractive" add-apt-repository ppa:ondrej/php +ENV DEBIAN_FRONTEND="noninteractive" +#RUN add-apt-repository ppa:ondrej/php # Install PHP extensions RUN apt-get update && apt-get install -y apt-utils git less libbz2-dev libc-client-dev \ @@ -16,18 +16,6 @@ RUN docker-php-ext-configure imap --with-imap --with-imap-ssl --with-kerberos RUN docker-php-ext-install bz2 curl imap intl mbstring mcrypt \ opcache soap xmlrpc zip -## set up Redis support for php -#RUN docker-php-source extract \ -# && curl -L -o /tmp/redis.tar.gz https://github.com/phpredis/phpredis/archive/$PHPREDIS_VERSION.tar.gz \ -# && tar xfz /tmp/redis.tar.gz \ -# && rm -r /tmp/redis.tar.gz \ -# && mv phpredis-$PHPREDIS_VERSION /usr/src/php/ext/redis \ -# && docker-php-ext-install redis \ -# && docker-php-source delete \ -# && curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar \ -# && chmod +x wp-cli.phar \ -# && mv wp-cli.phar /usr/local/bin/wp - # install GD RUN apt-get update && apt-get install -y \ libfreetype6-dev \ @@ -42,7 +30,7 @@ RUN apt-get update && apt-get install -y \ RUN apt-get install -y \ libyaml-dev unzip RUN pecl install yaml-2.0.0 -RUN docker-php-ext-enable yaml-2.0.0 +RUN docker-php-ext-enable yaml RUN pecl install apcu RUN docker-php-ext-enable apcu diff --git a/docker-compose.yml b/docker-compose.yml index a0a83a4..0da65b3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,9 +3,21 @@ version: "2" services: app: image: kiwilightweight/grav - ports: - - 127.0.0.1:9002:9000 +# ports: +# - 127.0.0.1:9002:9000 volumes: - - /home/dave/Projects/grav/test:/var/www/html +# - /home/dave/Projects/grav/test:/var/www/html + - /home/dave/Projects/grav/new:/var/www/html restart: unless-stopped + nginx: + image: oeru/nginx-jessie + links: + - app + ports: + - "127.0.0.1:8080:80" + volumes: + - ./nginx:/etc/nginx/conf.d + - ./nginx/cache:/var/cache/nginx + - /home/dave/Projects/grav/new:/var/www/html + restart: unless-stopped diff --git a/nginx.conf b/nginx.conf index 820e4b2..8c3f9d6 100644 --- a/nginx.conf +++ b/nginx.conf @@ -1,39 +1,24 @@ +# +# Set YOUR_DOMAIN, YOUR_WPMS_DIR, and YOUR_PORT below to make this work +# server { + # add [IP-Address:]80 in the next line if you want to limit this to a single interface listen 80; - index index.html index.php; - ## Web root and Domain Name - root /home/dave/Projects/grav/test; server_name grav.local; - ## Begin - Index - # for subfolders, simply adjust the rewrite: - # to use `/subfolder/index.php` - location / { - try_files $uri $uri/ /index.php?$query_string; - } - ## End - Index + root /var/www/html; + index index.php; - ## Begin - PHP-FPM Configuration - location ~ \.php$ { - # Choose either a socket or TCP/IP address - fastcgi_pass 127.0.0.1:9002; + # change the file name of these logs to include your server name + # if hosting many services... + access_log /var/log/nginx/grav.local_access.log; + error_log /var/log/nginx/grav.local_error.log; - fastcgi_split_path_info ^(.+\.php)(/.+)$; - fastcgi_index index.php; - include fastcgi_params; - fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name; + location / { + proxy_pass http://localhost:8080; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Conection "upgrade"; + proxy_set_header Host $http_host; } - ## End - PHP - - ## Begin - Security - # deny all direct access for these folders - location ~* /(.git|cache|bin|logs|backups)/.*$ { return 403; } - # deny running scripts inside core system folders - location ~* /(system|vendor)/.*\.(txt|xml|md|html|yaml|php|pl|py|cgi|twig|sh|bat)$ { return 403; } - # deny running scripts inside user folder - location ~* /user/.*\.(txt|md|yaml|php|pl|py|cgi|twig|sh|bat)$ { return 403; } - # deny access to specific files in the root folder - location ~ /(LICENSE|composer.lock|composer.json|nginx.conf|web.config|htaccess.txt|\.htaccess) { return 403; } - ## End - Security - } +} diff --git a/nginx/default.conf b/nginx/default.conf new file mode 100644 index 0000000..e533196 --- /dev/null +++ b/nginx/default.conf @@ -0,0 +1,39 @@ +server { + listen 80; + index index.html index.php; + + ## Web root and Domain Name + root /var/www/html; + server_name default; + + ## Begin - Index + # for subfolders, simply adjust the rewrite: + # to use `/subfolder/index.php` + location / { + try_files $uri $uri/ /index.php?$query_string; + } + ## End - Index + + ## Begin - PHP-FPM Configuration + location ~ \.php$ { + # Choose either a socket or TCP/IP address + fastcgi_pass app:9000; + + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_index index.php; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name; + } + ## End - PHP + + ## Begin - Security + # deny all direct access for these folders + location ~* /(.git|cache|bin|logs|backups)/.*$ { return 403; } + # deny running scripts inside core system folders + location ~* /(system|vendor)/.*\.(txt|xml|md|html|yaml|php|pl|py|cgi|twig|sh|bat)$ { return 403; } + # deny running scripts inside user folder + location ~* /user/.*\.(txt|md|yaml|php|pl|py|cgi|twig|sh|bat)$ { return 403; } + # deny access to specific files in the root folder + location ~ /(LICENSE|composer.lock|composer.json|nginx.conf|web.config|htaccess.txt|\.htaccess) { return 403; } + ## End - Security + } -- GitLab