Skip to content

Instantly share code, notes, and snippets.

@siddjain
Last active September 29, 2020 00:13
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 siddjain/14da6707bfcc23abf94e0fe67c295217 to your computer and use it in GitHub Desktop.
Save siddjain/14da6707bfcc23abf94e0fe67c295217 to your computer and use it in GitHub Desktop.
server {
listen 80;
server_name my-site.com;
root /var/www/html;
client_max_body_size 100M;
index index.php;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
if (!-e $request_filename) {
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
rewrite ^(/[^/]+)?(/wp-.*) $2 last;
rewrite ^(/[^/]+)?(/.*\.php) $2 last;
}
location / {
try_files $uri $uri/ index.php?$args;
}
# this will instruct browser to cache static resources so that it does not request them
# from server again. this causes page to load much much faster.
location ~* \.(map|js|css|png|jpg|jpeg|gif|ico)$ {
expires 30d;
add_header Cache-Control "public, no-transform";
}
# this location block does nothing but delegate requests for PHP files to the
# WORDPRESS_CONTAINER which runs a php-fpm server. php-fpm is
# PHPs implementation of the FastCGI protocol
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_pass business-wordpress:9000;
fastcgi_index index.php;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment