Skip to content

Instantly share code, notes, and snippets.

@amizz
Created October 6, 2018 06:05
Show Gist options
  • Save amizz/d2a0ecf247c27a41369c8e8ed13af555 to your computer and use it in GitHub Desktop.
Save amizz/d2a0ecf247c27a41369c8e8ed13af555 to your computer and use it in GitHub Desktop.
Nginx+Wordpress Subdirectory Configuration
server {
root /var/www/<domain>.com;
index index.php index.html index.htm index.nginx-debian.html;
server_name <domain>.com www.<domain>.com;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
location /blog/ {
try_files $uri $uri/ /blog/index.php?q=$uri$args;
}
location ~ /\.ht {
deny all;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/<domain>.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/<domain>.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = www.<domain>.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = <domain>.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name <domain>.com www.<domain>.com;
return 404; # managed by Certbot
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment