From d3e7563b86cf737f1fbbb3cce3a040b9487aa481 Mon Sep 17 00:00:00 2001 From: Adam Quaile Date: Wed, 14 Mar 2018 15:46:01 +0000 Subject: [PATCH 1/2] Replaced caddy with nginx --- Caddyfile | 14 -------------- Dockerfile | 8 ++++++-- Procfile | 2 +- infrastructure/nginx/nginx.conf | 25 +++++++++++++++++++++++++ 4 files changed, 32 insertions(+), 17 deletions(-) delete mode 100644 Caddyfile create mode 100644 infrastructure/nginx/nginx.conf diff --git a/Caddyfile b/Caddyfile deleted file mode 100644 index 3b98334..0000000 --- a/Caddyfile +++ /dev/null @@ -1,14 +0,0 @@ -:80 -root /app/web -gzip -fastcgi / 127.0.0.1:9000 php { - index app.php -} - -log stdout -errors stderr - -rewrite { - if {file} not favicon.ico - to {path} {path}/ /maintenance.html /app.php -} diff --git a/Dockerfile b/Dockerfile index e92563c..0f6c519 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,7 @@ RUN apk update --no-cache \ && apk add ca-certificates \ && apk add zlib-dev \ && apk add bash \ - && apk add caddy \ + && apk add nginx \ && apk add zip \ && apk add unzip \ && docker-php-source extract \ @@ -26,7 +26,11 @@ RUN infrastructure/scripts/install-composer.sh && \ COPY . /app RUN cp /app/infrastructure/php-fpm/php-fpm.conf /usr/local/etc/php-fpm.conf && \ - cp /app/infrastructure/php-fpm/www.conf /usr/local/etc/php-fpm.d/www.conf + cp /app/infrastructure/php-fpm/www.conf /usr/local/etc/php-fpm.d/www.conf && \ + cp /app/infrastructure/nginx/nginx.conf /etc/nginx/conf.d/default.conf + +RUN ln -sf /dev/stdout /var/log/nginx/access.log && ln -sf /dev/stderr /var/log/nginx/error.log + RUN chown -R www-data composer.phar var vendor ENV SYMFONY_ENV prod diff --git a/Procfile b/Procfile index 316efb8..e450532 100644 --- a/Procfile +++ b/Procfile @@ -1,2 +1,2 @@ -caddy: PYTHONUNBUFFERED=true /usr/sbin/caddy +caddy: PYTHONUNBUFFERED=true nginx -g 'pid /tmp/nginx.pid; daemon off;' php: /usr/local/sbin/php-fpm -F \ No newline at end of file diff --git a/infrastructure/nginx/nginx.conf b/infrastructure/nginx/nginx.conf new file mode 100644 index 0000000..ec6982d --- /dev/null +++ b/infrastructure/nginx/nginx.conf @@ -0,0 +1,25 @@ +server { + root /app/web; + listen 80 default_server; + + location / { + # try to serve file directly, fallback to app.php + try_files $uri /app.php$is_args$args; + } + # PROD + location ~ ^/app\.php(/|$) { + fastcgi_pass 127.0.0.1:9000; + fastcgi_split_path_info ^(.+\.php)(/.*)$; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; + fastcgi_param DOCUMENT_ROOT $realpath_root; + internal; + } + + # return 404 for all other php files not matching the front controller + # this prevents access to other php files you don't want to be accessible. + location ~ \.php$ { + return 404; + } + +} \ No newline at end of file From 187a81ef429566f8e8613e336f32ada8e688c05d Mon Sep 17 00:00:00 2001 From: Steve Todd Date: Wed, 14 Mar 2018 17:08:45 +0000 Subject: [PATCH 2/2] Update Procfile Change the name of the key --- Procfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Procfile b/Procfile index e450532..ffddc06 100644 --- a/Procfile +++ b/Procfile @@ -1,2 +1,2 @@ -caddy: PYTHONUNBUFFERED=true nginx -g 'pid /tmp/nginx.pid; daemon off;' -php: /usr/local/sbin/php-fpm -F \ No newline at end of file +nginx: PYTHONUNBUFFERED=true nginx -g 'pid /tmp/nginx.pid; daemon off;' +php: /usr/local/sbin/php-fpm -F