Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .htaccess
- `
- # BEGIN WordPress
- <IfModule mod_rewrite.c>
- RewriteEngine On
- RewriteBase /
- RewriteRule ^index\.php$ - [L]
- RewriteCond %{REQUEST_FILENAME} !-f
- RewriteCond %{REQUEST_FILENAME} !-d
- RewriteRule . /index.php [L]
- </IfModule>
- # END WordPress
- Header unset Pragma
- FileETag None
- Header unset ETag
- ## HIDE THE FACT THE SITE IS POWERED BY PHP ##
- <IfModule mod_headers.c>
- Header unset X-Powered-By
- Header unset Server
- </IfModule>
- # BEGIN Expire headers ##
- <ifModule mod_expires.c>
- ExpiresActive On
- ExpiresDefault "access plus 5 seconds"
- ExpiresByType image/x-icon "access plus 604800 seconds"
- ExpiresByType image/jpeg "access plus 604800 seconds"
- ExpiresByType image/png "access plus 604800 seconds"
- ExpiresByType image/gif "access plus 604800 seconds"
- ExpiresByType application/x-shockwave-flash "access plus 604800 seconds"
- ExpiresByType text/css "access plus 604800 seconds"
- ExpiresByType text/javascript "access plus 604800 seconds"
- ExpiresByType application/javascript "access plus 604800 seconds"
- ExpiresByType application/x-javascript "access plus 604800 seconds"
- #ExpiresByType text/html "access plus 600 seconds"
- #ExpiresByType application/xhtml+xml "access plus 600 seconds"
- </ifModule>
- ## ENABLE GZIP COMPRESSION ##
- <IfModule mod_deflate.c>
- <FilesMatch "\\.(js|css|html|htm|php|xml)$">
- SetOutputFilter DEFLATE
- </FilesMatch>
- </IfModule>
- <IfModule mod_gzip.c>
- mod_gzip_on Yes
- mod_gzip_dechunk Yes
- mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$
- mod_gzip_item_include handler ^cgi-script$
- mod_gzip_item_include mime ^text/.*
- mod_gzip_item_include mime ^application/x-javascript.*
- mod_gzip_item_exclude mime ^image/.*
- mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
- </IfModule>
- ## PAGESPEED MODULE ##
- <IfModule pagespeed_module>
- ModPagespeed on
- ModPagespeedEnableFilters
- extend_cache,combine_css,combine_javascript,collapse_whitespace,move_css_to_head
- </IfModule>
- # BEGIN Cache-Control Headers
- <IfModule mod_headers.c>
- <filesMatch "\.(ico|jpe?g|png|gif|swf)$">
- Header set Cache-Control "public"
- </filesMatch>
- <filesMatch "\.(css)$">
- Header set Cache-Control "public"
- </filesMatch>
- <filesMatch "\.(js)$">
- Header set Cache-Control "private"
- </filesMatch>
- <filesMatch "\.(x?html?|php)$">
- Header set Cache-Control "private, must-revalidate"
- </filesMatch>
- </IfModule>
- # VARY Accept-Encoding Headers
- <IfModule mod_headers.c>
- <FilesMatch ".(js|css|xml|gz|html)$">
- Header append Vary: Accept-Encoding
- </FilesMatch>
- </IfModule>
- <FilesMatch "^.*(error_log|wp-config\.php|php.ini|\.[hH][tT][aApP].*)$">
- Order deny,allow
- Deny from all
- </FilesMatch>
- <IfModule mod_rewrite.c>
- RewriteEngine on
- RewriteCond %{HTTP_REFERER} !^$
- RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?domain.com [NC]
- RewriteRule \.(jpg|jpeg|png|gif)$ http://domain.com/wp-content/uploads/2015/03/hotlinking.png [NC,R,L]
- </IfModule>
- `
- nginx.conf
- `
- user www-data;
- worker_processes 1;
- pid /run/nginx.pid;
- events {
- worker_connections 1024;
- # multi_accept on;
- }
- http {
- ##
- # Basic Settings
- ##
- sendfile on;
- tcp_nopush on;
- tcp_nodelay on;
- keepalive_timeout 65;
- types_hash_max_size 2048;
- server_tokens off;
- client_max_body_size 15m;
- client_body_timeout 60;
- client_header_timeout 60;
- client_body_buffer_size 1K;
- client_header_buffer_size 1k;
- large_client_header_buffers 4 8k;
- send_timeout 60;
- reset_timedout_connection on;
- # server_names_hash_bucket_size 64;
- # server_name_in_redirect off;
- include /etc/nginx/mime.types;
- default_type application/octet-stream;
- ##
- # SSL Settings
- ##
- ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
- ssl_prefer_server_ciphers on;
- ##
- # Logging Settings
- ##
- access_log /var/log/nginx/access.log;
- error_log /var/log/nginx/error.log;
- ##
- # Gzip Settings
- ##
- gzip on;
- gzip_disable "msie6";
- gzip_vary on;
- gzip_proxied any;
- gzip_comp_level 6;
- gzip_buffers 16 8k;
- gzip_http_version 1.1;
- gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript text/x-component application/x-javascript font/truetype application/x-font-ttf font/opentype application/vnd.ms-fontobject image/svg+xml;
- ##
- # Virtual Host Configs
- ##
- include /etc/nginx/conf.d/*.conf;
- include /etc/nginx/sites-enabled/*;
- }
- #mail {
- # # See sample authentication script at:
- # # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
- #
- # # auth_http localhost/auth.php;
- # # pop3_capabilities "TOP" "USER";
- # # imap_capabilities "IMAP4rev1" "UIDPLUS";
- #
- # server {
- # listen localhost:110;
- # protocol pop3;
- # proxy on;
- # }
- #
- # server {
- # listen localhost:143;
- # protocol imap;
- # proxy on;
- # }
- #}
- `
- nginx/sites-enabled/site
- `
- # You may add here your
- # server {
- # ...
- # }
- # statements for each of your virtual hosts to this file
- ##
- # You should look at the following URL's in order to grasp a solid understanding
- # of Nginx configuration files in order to fully unleash the power of Nginx.
- # http://wiki.nginx.org/Pitfalls
- # http://wiki.nginx.org/QuickStart
- # http://wiki.nginx.org/Configuration
- #
- # Generally, you will want to move this file somewhere, and start with a clean
- # file but keep this around for reference. Or just disable in sites-enabled.
- #
- # Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
- #
- server {
- listen 127.0.0.1:8080; ## listen for ipv4; this line is default and implied
- #listen [::]:80 default ipv6only=on; ## listen for ipv6
- root /var/www;
- index index.php index.html index.htm;
- # Make site accessible from http://localhost/
- server_name domain.com;
- client_body_buffer_size 10K;
- client_header_buffer_size 1k;
- client_max_body_size 80m;
- large_client_header_buffers 2 1k;
- client_body_timeout 12;
- client_header_timeout 12;
- keepalive_timeout 15;
- send_timeout 10;
- #Fix Yoast SEO Sitemaps
- rewrite ^/sitemap_index\.xml$ /index.php?sitemap=1 last;
- rewrite ^/([^/]+?)-sitemap([0-9]+)?\.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;
- # Use gzip compression
- gzip_static on; # Uncomment if you compiled Nginx using --with-http_gzip_static_module
- gzip on;
- gzip_disable "msie6";
- gzip_vary on;
- gzip_proxied any;
- gzip_comp_level 6;
- gzip_buffers 16 8k;
- gzip_http_version 1.1;
- gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript image/png image/gif image/jpeg text/x-component application/javascript font/truetype application/x-font-ttf font/opentype application/vnd.ms-fontobject image/svg+xml;
- # Cache static files for as long as possible - removed xml as an extension to avoid problems with Yoast WordPress SEO plugin which uses WP rewrite API.
- 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)$ {
- try_files $uri =404;
- expires max;
- access_log off;
- log_not_found off;
- add_header Pragma public;
- }
- # Deny access to hidden files
- location ~* /\.ht {
- deny all;
- access_log off;
- log_not_found off;
- }
- # Rewrite minified CSS and JS files
- #rewrite ^/wp-content/w3tc/min/([a-f0-9]+)\/(.+)\.(include(\-(footer|body))?(-nb)?)\.[0-9]+\.(css|js)$ /wp-content/w3tc/min/index.php?tt=$1&gg=$2&g=$3&t=$7 last;
- # Set a variable to work around the lack of nested conditionals
- set $cache_uri $request_uri;
- # POST requests and urls with a query string should always go to PHP
- if ($request_method = POST) {
- set $cache_uri 'no cache';
- }
- if ($query_string != "") {
- set $cache_uri 'no cache';
- }
- # Don't cache uris containing the following segments
- if ($request_uri ~* "(\/wp-admin\/|\/xmlrpc.php|\/wp-(app|cron|login|register|mail)\.php|wp-.*\.php|index\.php|wp\-comments\-popup\.php|wp\-links\-opml\.php|wp\-locations\.php)") {
- set $cache_uri "no cache";
- }
- # Don't use the cache for logged in users or recent commenters
- if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp\-postpass|wordpress_logged_in") {
- set $cache_uri 'no cache';
- }
- location / {
- # First attempt to serve request as file, then
- # as directory, then fall back to index.html
- try_files /wp-content/cache/wp-rocket/$http_host/$cache_uri/index.html $uri/ /index.php?q=$uri&$args;
- # Uncomment to enable naxsi on this location
- # include /etc/nginx/naxsi.rules
- }
- location /doc/ {
- alias /usr/share/doc/;
- autoindex on;
- allow 127.0.0.1;
- deny all;
- }
- # Only for nginx-naxsi : process denied requests
- #location /RequestDenied {
- # For example, return an error code
- #return 418;
- #}
- error_page 404 /404.html;
- # redirect server error pages to the static page /50x.html
- #
- error_page 500 502 503 504 /50x.html;
- location = /50x.html {
- root /usr/share/nginx/www;
- }
- # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
- #
- location ~ \.php$ {
- try_files $uri =404;
- fastcgi_split_path_info ^(.+\.php)(/.+)$;
- fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
- fastcgi_pass unix:/var/run/php5-fpm.sock;
- fastcgi_index index.php;
- include fastcgi_params;
- fastcgi_param QUERY_STRING $query_string;
- fastcgi_param REQUEST_METHOD $request_method;
- fastcgi_param CONTENT_TYPE $content_type;
- fastcgi_param CONTENT_LENGTH $content_length;
- fastcgi_intercept_errors off;
- fastcgi_ignore_client_abort off;
- fastcgi_connect_timeout 60;
- fastcgi_send_timeout 180;
- fastcgi_read_timeout 600;
- fastcgi_buffer_size 128k;
- fastcgi_buffers 4 256k;
- fastcgi_busy_buffers_size 256k;
- fastcgi_temp_file_write_size 256k;
- }
- # deny access to .htaccess files, if Apache's document root
- # concurs with nginx's one
- #
- location ~ /\.ht {
- deny all;
- }
- location ~ /.git {
- deny all;
- }
- location ~ /.svn {
- deny all;
- }
- }
- # another virtual host using mix of IP-, name-, and port-based configuration
- #
- #server {
- # if ($host ~* ^domain\.com$) {
- # rewrite ^(.*) http://domain.com$1 permanent;
- # break;
- #}
- #}
- # listen 8000;
- # listen somename:8080;
- # server_name somename alias another.alias;
- # root html;
- # index index.html index.htm;
- #
- # location / {
- # try_files $uri $uri/ /index.html;
- # }
- #}
- # HTTPS server
- #
- #server {
- # listen 443;
- # server_name localhost;
- #
- # root html;
- # index index.html index.htm;
- #
- # ssl on;
- # ssl_certificate cert.pem;
- # ssl_certificate_key cert.key;
- #
- # ssl_session_timeout 5m;
- #
- # ssl_protocols SSLv3 TLSv1;
- # ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;
- # ssl_prefer_server_ciphers on;
- #
- # location / {
- # try_files $uri $uri/ /index.html;
- # }
- #}
- `
- varnish/default.vcl
- `
- # This is a basic VCL configuration file for varnish. See the vcl(7)
- # man page for details on VCL syntax and semantics.
- #
- # Default backend definition. Set this to point to your content
- # server.
- #
- backend default {
- .host = "127.0.0.1";
- .port = "8080";
- .connect_timeout = 20s;
- .first_byte_timeout = 30s;
- .between_bytes_timeout = 20s;
- }
- acl purge {
- "127.0.0.1";
- }
- sub vcl_recv {
- # Allow purge requests
- if (req.request == "PURGE") {
- if (!client.ip ~ purge) {
- error 405 "Not allowed.";
- }
- ban("req.url ~ ^" + req.url + " && req.http.host == " + req.http.host);
- return(lookup);
- }
- # Normalize content-encoding
- if (req.http.Accept-Encoding) {
- if (req.http.Accept-Encoding ~ "gzip") {
- # If the browser supports it, we'll use gzip.
- set req.http.Accept-Encoding = "gzip";
- }
- else if (req.http.Accept-Encoding ~ "deflate") {
- # Next, try deflate if it is supported.
- set req.http.Accept-Encoding = "deflate";
- }
- else {
- # Unknown algorithm. Remove it and send unencoded.
- unset req.http.Accept-Encoding;
- }
- }
- #Don't cache admin or login pages
- if (req.url ~ "wp-(login|admin)" || req.url ~ "preview=true") {
- return (pass);
- }
- #Don't cache logged in users
- if (req.http.Cookie && req.http.Cookie ~ "(wordpress_|wordpress_logged_in|comment_author_)") {
- return(pass);
- }
- #Don't cache ajax requests, urls with ?nocache or comments/login/regiser
- if(req.http.X-Requested-With == "XMLHttpRequest" || req.url ~ "nocache" || req.url ~ "(control.php|wp-comments-post.php|wp-login.php|register.php)") {
- return (pass);
- }
- # always pass through POST requests and those with basic auth
- if (req.http.Authorization || req.request == "POST") {
- return (pass);
- }
- # Do not cache these paths
- if (req.url ~ "^/wp-cron\.php$" ||
- req.url ~ "^/xmlrpc\.php$" ||
- req.url ~ "^/wp-admin/.*$" ||
- req.url ~ "^/wp-includes/.*$" ||
- req.url ~ "\?s=") {
- return (pass);
- }
- # Remove cookies and query string for real static files
- if (req.url ~ "^/[^?]+\.(gif|jpg|jpeg|swf|css|js|txt|flv|mp3|mp4|pdf|ico|png|gz|zip|lzma|bz2|tgz|tbz)(\?.*|)$") {
- unset req.http.cookie;
- set req.url = regsub(req.url, "\?.*$", "");
- }
- # Define the default grace period to serve cached content
- set req.grace = 30s;
- # Set client IP
- if (req.http.x-forwarded-for) {
- set req.http.X-Forwarded-For =
- req.http.X-Forwarded-For + ", " + client.ip;
- } else {
- set req.http.X-Forwarded-For = client.ip;
- }
- }
- sub vcl_hit {
- # purge cached objects from memory
- if (req.request == "PURGE") {
- purge;
- error 200 "Purged";
- }
- }
- sub vcl_miss {
- # Set up invalidation of the cache so purging gets done properly
- if (req.request == "PURGE") {
- purge;
- error 200 "Purged.";
- }
- return (fetch);
- }
- sub vcl_fetch {
- # Dont cache admin
- if (req.url ~ "(wp-(login|admin|comments-post.php|cron.php))|login" || req.url ~ "preview=true" || req.url ~ "xmlrpc.php") {
- return (hit_for_pass);
- }
- if (req.http.Cookie ~"(wp-postpass|wordpress_logged_in|comment_author_)") {
- return (hit_for_pass);
- }
- # remove some headers we never want to see
- unset beresp.http.Server;
- unset beresp.http.X-Powered-By;
- # only cache status ok
- if ( beresp.status != 200 ) {
- return (hit_for_pass);
- }
- # If our backend returns 5xx status this will reset the grace time
- # set in vcl_recv so that cached content will be served and
- # the unhealthy backend will not be hammered by requests
- if (beresp.status == 500) {
- set beresp.grace = 60s;
- return (restart);
- }
- # GZip the cached content if possible
- if (beresp.http.content-type ~ "text") {
- set beresp.do_gzip = true;
- }
- # if nothing abovce matched it is now ok to cache the response
- set beresp.ttl = 24h;
- return (deliver);
- }
- sub vcl_error {
- if (obj.status == 503) {
- # set obj.http.location = req.http.Location;
- set obj.status = 404;
- set obj.response = "Not Found";
- return (deliver);
- }
- }
- sub vcl_deliver {
- # remove some headers added by varnish
- unset resp.http.Via;
- unset resp.http.X-Varnish;
- }
- # commented-out copy of the default VCL logic. If you
- # redefine any of these subroutines, the built-in logic will be
- # appended to your code.
- # sub vcl_recv {
- # if (req.restarts == 0) {
- # if (req.http.x-forwarded-for) {
- # set req.http.X-Forwarded-For =
- # req.http.X-Forwarded-For + ", " + client.ip;
- # } else {
- # set req.http.X-Forwarded-For = client.ip;
- # }
- # }
- # if (req.request != "GET" &&
- # req.request != "HEAD" &&
- # req.request != "PUT" &&
- # req.request != "POST" &&
- # req.request != "TRACE" &&
- # req.request != "OPTIONS" &&
- # req.request != "DELETE") {
- # /* Non-RFC2616 or CONNECT which is weird. */
- # return (pipe);
- # }
- # if (req.request != "GET" && req.request != "HEAD") {
- # /* We only deal with GET and HEAD by default */
- # return (pass);
- # }
- # if (req.http.Authorization || req.http.Cookie) {
- # /* Not cacheable by default */
- # return (pass);
- # }
- # return (lookup);
- # }
- #
- # sub vcl_pipe {
- # # Note that only the first request to the backend will have
- # # X-Forwarded-For set. If you use X-Forwarded-For and want to
- # # have it set for all requests, make sure to have:
- # # set bereq.http.connection = "close";
- # # here. It is not set by default as it might break some broken web
- # # applications, like IIS with NTLM authentication.
- # return (pipe);
- # }
- #
- # sub vcl_pass {
- # return (pass);
- # }
- #
- # sub vcl_hash {
- # hash_data(req.url);
- # if (req.http.host) {
- # hash_data(req.http.host);
- # } else {
- # hash_data(server.ip);
- # }
- # return (hash);
- # }
- #
- # sub vcl_hit {
- # return (deliver);
- # }
- #
- # sub vcl_miss {
- # return (fetch);
- # }
- #
- # sub vcl_fetch {
- # if (beresp.ttl <= 0s ||
- # beresp.http.Set-Cookie ||
- # beresp.http.Vary == "*") {
- # /*
- # * Mark as "Hit-For-Pass" for the next 2 minutes
- # */
- # set beresp.ttl = 120 s;
- # return (hit_for_pass);
- # }
- # return (deliver);
- # }
- #
- # sub vcl_deliver {
- # return (deliver);
- # }
- #
- # sub vcl_error {
- # set obj.http.Content-Type = "text/html; charset=utf-8";
- # set obj.http.Retry-After = "5";
- # synthetic {"
- # <?xml version="1.0" encoding="utf-8"?>
- # <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- # "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- # <html>
- # <head>
- # <title>"} + obj.status + " " + obj.response + {"</title>
- # </head>
- # <body>
- # <h1>Error "} + obj.status + " " + obj.response + {"</h1>
- # <p>"} + obj.response + {"</p>
- # <h3>Guru Meditation:</h3>
- # <p>XID: "} + req.xid + {"</p>
- # <hr>
- # <p>Varnish cache server</p>
- # </body>
- # </html>
- # "};
- # return (deliver);
- # }
- #
- # sub vcl_init {
- # return (ok);
- # }
- #
- # sub vcl_fini {
- # return (ok);
- # }
- `
Advertisement
Add Comment
Please, Sign In to add comment