tractorcow / silverstripe-dynamiccache

Simple on the fly caching of dynamic content for Silverstripe
39 stars 27 forks source link

Nginx #22

Closed selay closed 9 years ago

selay commented 9 years ago

Hi, the provided RewriteRule .* dynamiccache/cache-main.php?url=%1&%{QUERY_STRING} [L] is fine for Apache. How about Nginx? http://doc.silverstripe.org/en/getting_started/installation/how_to/configure_nginx How it should be modified for dynamiccache?

tractorcow commented 9 years ago

Just a guess

server {
    listen 80;
    root /path/to/ss/folder;

    server_name site.com www.site.com;

    location / {
        try_files $uri /dynamiccache/cache-main.php?url=$uri&$query_string;
    }

    error_page 404 /assets/error-404.html;
    error_page 500 /assets/error-500.html;

    location ^~ /assets/ {
        sendfile on;
        try_files $uri =404;
    }

    location ~ /(framework|dynamiccache)/.*(cache-main|main|rpc|tiny_mce_gzip)\.php$ {
        fastcgi_keep_conn on;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

    location ~ /(mysite|framework|cms)/.*\.(php|php3|php4|php5|phtml|inc)$ {
        deny all;
    }

    location ~ /\.. {
        deny all;
    }

    location ~ \.ss$ {
        satisfy any;
        allow 127.0.0.1;
        deny all;
    }

    location ~ web\.config$ {
        deny all;
    }

    location ~ \.ya?ml$ {
        deny all;
    }

    location ^~ /vendor/ {
        deny all;
    }

    location ~* /silverstripe-cache/ {
        deny all;
    }

    location ~* composer\.(json|lock)$ {
        deny all;
    }

    location ~* /(cms|framework)/silverstripe_version$ {
        deny all;
    }

    location ~ \.php$ {
        fastcgi_keep_conn on;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include        fastcgi_params;
        fastcgi_buffer_size 32k;
        fastcgi_busy_buffers_size 64k;
        fastcgi_buffers 4 32k;
    }
}
selay commented 9 years ago

It works. Thank you very much.

tractorcow commented 9 years ago

Cheers. :) I should add this to the docs.