Skip to content

Instantly share code, notes, and snippets.

@danfoust
Created November 23, 2020 02:39
Show Gist options
  • Save danfoust/f6754e49502b4c8c1b8ac9debaeeb20f to your computer and use it in GitHub Desktop.
Save danfoust/f6754e49502b4c8c1b8ac9debaeeb20f to your computer and use it in GitHub Desktop.
Basic Nginx + PHP-FPM Docker config
server {
listen 80;
index index.php index.html;
server_name localhost;
root /var/www/html;
error_log /var/log/nginx/error;
access_log /var/log/nginx/access;
location / {
# Try to serve file directly, fallback to index.php
try_files $uri /index.php$is_args$args;
}
location ~ ^/index\.php(/|$) {
fastcgi_pass wordpress_service:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
internal;
}
location ~ \.php$ {
return 404;
}
}
FROM nginx:1.19.4-alpine
COPY default.conf /etc/nginx/conf.d/
WORKDIR /var/www/html
FROM wordpress:php7.4-fpm-alpine
WORKDIR /var/www/html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment