Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- **/nginx/global/common.conf**
- # Global configuration file.
- # ESSENTIAL : Configure Nginx Listening Port
- listen 80;
- # ESSENTIAL : Default file to serve. If the first file isn't found,
- index index.php index.html index.htm;
- # ESSENTIAL : no favicon logs
- location = /favicon.ico {
- log_not_found off;
- access_log off;
- }
- # ESSENTIAL : robots.txt
- location = /robots.txt {
- allow all;
- log_not_found off;
- access_log off;
- }
- # ESSENTIAL : Configure 404 Pages
- error_page 404 /404.html;
- # ESSENTIAL : Configure 50x Pages
- error_page 500 502 503 504 /50x.html;
- location = /50x.html {
- root /usr/share/nginx/html;
- }
- # SECURITY : Deny all attempts to access hidden files .abcde
- location ~ /\. {
- deny all;
- }
- # PERFORMANCE : Set expires headers for static files and turn off logging.
- location ~* ^.+\.(js|css|swf|xml|txt|ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
- access_log off; log_not_found off; expires 30d;
- }
- **/nginx/global/wordpress.conf**
- # WORDPRESS : Rewrite rules, sends everything through index.php and keeps the appended query string intact
- location / {
- try_files $uri $uri/ /index.php?q=$uri&$args;
- }
- # SECURITY : Deny all attempts to access PHP Files in the uploads directory
- location ~* /(?:uploads|files)/.*\.php$ {
- deny all;
- }
- # REQUIREMENTS : Enable PHP Support
- location ~ \.php$ {
- # SECURITY : Zero day Exploit Protection
- try_files $uri =404;
- # ENABLE : Enable PHP, listen fpm sock
- fastcgi_split_path_info ^(.+\.php)(/.+)$;
- fastcgi_pass unix:/var/run/php5-fpm.sock;
- fastcgi_index index.php;
- include fastcgi_params;
- }
- # PLUGINS : Enable Rewrite Rules for Yoast SEO SiteMap
- rewrite ^/sitemap_index\.xml$ /index.php?sitemap=1 last;
- rewrite ^/([^/]+?)-sitemap([0-9]+)?\.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;
- **/nginx/global/multisite.conf**
- # Rewrite rules for WordPress Multi-site.
- if (!-e $request_filename) {
- rewrite /wp-admin$ $scheme://$host$uri/ permanent;
- rewrite ^/[_0-9a-zA-Z-]+(/wp-.*) $1 last;
- rewrite ^/[_0-9a-zA-Z-]+(/.*\.php)$ $1 last;
- }
- **/nginx/sites-available/example.com**
- server {
- # URL: Correct way to redirect URL's
- server_name example.com;
- rewrite ^/(.*)$ http://www.example.com/$1 permanent;
- }
- server {
- server_name www.example.com;
- root /usr/share/nginx/html/example;
- access_log /var/log/nginx/www.example.com.access.log;
- error_log /var/log/nginx/www.example.com.error.log;
- include global/common.conf;
- include global/wordpress.conf;
- include global/multisite.conf;
- }
Advertisement