Created
October 14, 2018 11:32
-
-
Save abhishekbhardwaj/7c6386016ee99040ea17de71ccaa6112 to your computer and use it in GitHub Desktop.
Add Nginx to WordPress's official FPM binaries and let users customize php settings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM wordpress:4.9-php7.2-fpm-alpine | |
# Install the extra packages. | |
RUN apk --no-cache add nginx supervisor curl | |
# Copy all files. | |
COPY ./php.ini $PHP_INI_DIR/conf.d/wp_php.ini | |
COPY ./nginx.conf /etc/nginx/nginx.conf | |
COPY ./supervisord.conf /etc/supervisor/conf.d/supervisord.conf | |
# Disable default entrypoint. | |
ENTRYPOINT [] | |
# Expose Nginx on 80. | |
EXPOSE 80 | |
# Run the entrypoint manually. Then start Supervisor. | |
CMD ["sh", "-c", "docker-entrypoint.sh php-fpm -v; /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
worker_processes 1; | |
pid /run/nginx.pid; | |
events { | |
worker_connections 1024; | |
} | |
http { | |
include mime.types; | |
default_type application/octet-stream; | |
log_format main_timed '$remote_addr - $remote_user [$time_local] "$request" ' | |
'$status $body_bytes_sent "$http_referer" ' | |
'"$http_user_agent" "$http_x_forwarded_for" ' | |
'$request_time $upstream_response_time $pipe $upstream_cache_status'; | |
access_log /dev/stdout main_timed; | |
error_log /dev/stderr notice; | |
keepalive_timeout 65; | |
server_tokens off; | |
# Enable gzip compression | |
gzip on; | |
gzip_disable "msie6"; | |
gzip_proxied any; | |
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript; | |
# Forward the cloudfront scheme from upstream | |
map "$http_cloudfront_forwarded_proto$http_x_forwarded_proto" $forwarded_scheme { | |
default off; | |
"~*(https)" on; | |
} | |
server { | |
listen [::]:80 default_server; | |
listen 80 default_server; | |
server_name _; | |
sendfile off; | |
# Increase proxy buffers for large requests | |
proxy_buffer_size 128k; | |
proxy_buffers 4 256k; | |
proxy_busy_buffers_size 256k; | |
# Upload limit | |
client_max_body_size 50m; | |
client_body_buffer_size 128k; | |
root /var/www/html; | |
index index.php index.html; | |
# redirect server error pages to the static page /50x.html | |
error_page 500 502 503 504 /50x.html; | |
location = /50x.html { | |
root /var/lib/nginx/html; | |
} | |
location = /favicon.ico { | |
log_not_found off; | |
access_log off; | |
} | |
location = /robots.txt { | |
log_not_found off; | |
access_log off; | |
} | |
location / { | |
# First attempt to serve request as file, then | |
# as directory, then fall back to index.php | |
try_files $uri $uri/ /index.php?$args; | |
} | |
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 | |
location ~ \.php$ { | |
try_files $uri =404; | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
#fastcgi_intercept_errors on; | |
fastcgi_buffer_size 128k; | |
fastcgi_buffers 4 256k; | |
fastcgi_busy_buffers_size 256k; | |
fastcgi_index index.php; | |
fastcgi_pass 127.0.0.1:9000; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
include fastcgi_params; | |
# Forward the scheme from upstream | |
fastcgi_param HTTPS $forwarded_scheme; | |
} | |
# deny access to . files, for security | |
location ~ /\. { | |
log_not_found off; | |
deny all; | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Don't fix path | |
cgi.fix_pathinfo = 0; | |
; File upload limit | |
file_uploads = On; | |
post_max_size = 100M; | |
upload_max_filesize = 50M; | |
; Memory limit | |
memory_limit = 512M; | |
; Set default timezone | |
date.timezone = "UTC"; | |
; Hide PHP version info in response headers | |
expose_php = Off; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[supervisord] | |
nodaemon=true | |
logfile=/var/log/supervisord.log | |
pidfile=/run/supervisord.pid | |
[program:php-fpm] | |
command=php-fpm -F | |
stdout_logfile=/dev/stdout | |
stdout_logfile_maxbytes=0 | |
redirect_stderr=true | |
autorestart=false | |
startretries=0 | |
[program:nginx] | |
command=nginx -g 'daemon off;' | |
stdout_logfile=/dev/stdout | |
stdout_logfile_maxbytes=0 | |
redirect_stderr=true | |
autorestart=false | |
startretries=0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment