Skip to content

Instantly share code, notes, and snippets.

@magician11 magician11/goforself.me
Last active Mar 1, 2018

Embed
What would you like to do?
Server block example for a WordPress site on Nginx on a DigitalOcean droplet
server {
server_name www.goforself.me goforself.me;
listen 80;
client_max_body_size 20M;
port_in_redirect off;
access_log /var/log/nginx/goforself.me.access.log;
error_log /var/log/nginx/goforself.me.error.log error;
root /var/www/goforself;
index index.php;
location / {
try_files $uri $uri/ /index.php?$args;
}
# Cache static files for as long as possible
location ~*.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf|cur)$ {
expires max;
log_not_found off;
access_log off;
}
# Deny public access to wp-config.php
location ~* wp-config.php {
deny all;
}
location ~ \.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.