Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
server {
listen 80;
server_name DEFAULT_SERVER_NAME;
return 301 https://DOMAINNAME$request_uri$is_args$args;
}
server {
listen 80;
server_name *.DOMAINNAME;
#Rewrite all nonssl requests to ssl.
return 301 https://DOMAINNAME$request_uri$is_args$args;
}
server {
listen 80;
listen [::]:80 default_server ipv6only=on;
listen 443 ssl;
listen [::]:443 ssl;
server_name SERVER_NAME;
ssl_certificate /etc/letsencrypt/live/DOMAINNAME/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/DOMAINNAME/privkey.pem;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
rewrite_log on;
access_log on;
root /PATH/TO/PROJECT;
index index.html index.htm index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
# Remove trailing slash.
if (!-d $request_filename) {
rewrite ^/(.+)/$ /$1 permanent;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass PHP_FPM_IP:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors off;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
}
# We don't need .ht files with Nginx.
location ~ /\.ht {
deny all;
}
location ~ /.well-known {
allow all;
}
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
}
FROM php:7-fpm
COPY . /PATH/TO/PROJECT
WORKDIR /PATH/TO/PROJECT
RUN apt-get update && apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libmcrypt-dev \
libpng12-dev \
&& chown -R www-data /PATH/TO/PROJECT \
&& chmod -R gu+w /PATH/TO/PROJECT/storage \
&& chmod -R guo+w /PATH/TO/PROJECT/storage \
&& docker-php-ext-install -j$(nproc) iconv pdo pdo_mysql mcrypt gd \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& pecl install zip \
&& docker-php-ext-enable zip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment