Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save g3luka/487afdd28b58f18572eb0543c9c64b81 to your computer and use it in GitHub Desktop.
Save g3luka/487afdd28b58f18572eb0543c9c64b81 to your computer and use it in GitHub Desktop.
WordPress Beanstalk Nginx Amazon Linux 2
location ~ ^(/[^/]+/)?files/(.+) {
try_files /wp-content/blogs.dir/$blogid/files/$2 /wp-includes/ms-files.php?file=$2 ;
access_log off; log_not_found off; expires max;
}
#avoid php readfile()
location ^~ /blogs.dir {
internal;
alias /var/app/current/wp-content/blogs.dir ;
access_log off; log_not_found off; expires max;
}
if (!-e $request_filename) {
rewrite /wp-admin$ $scheme://$host$request_uri/ permanent;
rewrite ^(/[^/]+)?(/wp-.*) $2 last;
rewrite ^(/[^/]+)?(/.*\.php) $2 last;
}
location / {
try_files $uri $uri/ /index.php?$args ;
}
location ~ \.php$ {
try_files $uri =404;
# include fastcgi_params;
# fastcgi_pass php;
}
map $uri $blogname {
~^(?P<blogpath>/[^/]+/)files/(.*) $blogpath ;
}
map $blogname $blogid {
default -999;
#Ref: https://wordpress.org/extend/plugins/nginx-helper/
#include /var/app/current/wp-content/uploads/nginx-helper/map.conf;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment