Skip to content

Instantly share code, notes, and snippets.

@rayriffy
Created September 15, 2018 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rayriffy/f9a7564f0c7bfd4cdd7cf7b3aa23ba1f to your computer and use it in GitHub Desktop.
Save rayriffy/f9a7564f0c7bfd4cdd7cf7b3aa23ba1f to your computer and use it in GitHub Desktop.
FROM nginx:1.15.3-alpine
COPY site-template.conf /etc/nginx/conf.d/site.template
CMD sh -c "envsubst '\$SERVER_NAME \$ROOT \$PHP_BACKEND' < /etc/nginx/conf.d/site.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'"
server {
listen 80;
listen [::]:80;
index index.html index.php;
server_name ${SERVER_NAME};
root ${ROOT};
error_log /var/log/nginx/${SERVER_NAME}.error.log error;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_pass ${PHP_BACKEND}:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
fastcgi_intercept_errors off;
fastcgi_hide_header X-Powered-By;
fastcgi_buffer_size 128k;
fastcgi_buffers 256 16k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
include fastcgi_params;
# Prevents URIs that include the front controller. This will 404:
# http://domain.tld/index.php/some-path
# Remove the internal directive to allow URIs like this
internal;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment