Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # You may add your server blocks inside "server brackets" { }
- server {
- listen 80;
- root /var/www/example.com/public_html;
- index index.php index.html index.htm;
- server_name www.example.com example.com;
- #The location block below will make sure if a some other file/directory exist, it will be served first.
- #If that fails, request will be checked inside /custom-wp-directory/ i.e. /blog/ directory.
- #So, if you install WP inside a /custom/ dir. instead of the root dir. it will work out of the box!
- #More info: https://rtcamp.com/support/topic/accessing-non-wordpress-directory-in-website-root/
- location / {
- try_files $uri $uri/ /custom-wp-directory/index.php?q=$uri&$args;
- }
- # Define default caching of 24h
- expires 86400s;
- add_header Pragma public;
- add_header Cache-Control "max-age=86400, public, must-revalidate, proxy-revalidate";
- # Add trailing slash to */wp-admin requests.
- rewrite /wp-admin$ $scheme://$host$uri/ permanent;
- # deliver a static 404
- error_page 404 /404.html;
- error_page 500 502 503 504 /50x.html;
- location = /50x.html {
- root /usr/share/nginx/www;
- }
- # Don't log robots.txt requests
- location = /robots.txt {
- allow all;
- log_not_found off;
- access_log off;
- }
- # Rewrite for versioned CSS+JS via filemtime
- location ~* ^.+\.(css|js)$ {
- rewrite ^(.+)\.(\d+)\.(css|js)$ $1.$3 last;
- expires 31536000s;
- access_log off;
- log_not_found off;
- add_header Pragma public;
- add_header Cache-Control "max-age=31536000, public";
- }
- # Aggressive caching for static files
- # If you alter static files often, please uncomment the add_header Cache-Control and use it
- add_header Cache-Control "max-age=31536000, public, must-revalidate, proxy-revalidate";
- location ~* \.(asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|odb|odc|odf|odg|odp|ods|odt|ogg|ogv|otf|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|t?gz|tif|tiff|ttf|wav|webm|wma|woff|wri|xla|xls|xlsx|xlt|xlw|zip)$
- {
- expires 31536000s;
- access_log off;
- log_not_found off;
- add_header Pragma public;
- add_header Cache-Control "max-age=31536000, public";
- }
- # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
- location ~ \.php$ {
- try_files $uri =404;
- #fastcgi_pass 127.0.0.1:9000;
- # With php5-fpm:
- fastcgi_pass unix:/var/run/php5-fpm.sock;
- fastcgi_index index.php;
- include fastcgi_params;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment