для меня в новость, пока первое знакомство.
Может кто поделится изящным конфигом под phpBB(ex).
Список разделов › phpBBex 1.x (поддерживается) › Поддержка 1.x
fastcgi_cache_path "%sprogdir%/userdata/temp/nginx-cache" levels=1:2 keys_zone=MYSITE:500m inactive=60m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
fastcgi_cache_use_stale error timeout invalid_header http_500;
server {
#fastcgi_cache start
set $no_cache 0;
# POST requests and urls with a query string should always go to PHP
if ($request_method = POST) {
set $no_cache 1;
}
if ($query_string != "") {
set $no_cache 1;
}
# Don't cache uris containing the following segments
if ($request_uri ~* "(/adm/|перечисляем исключения).php") {
set $no_cache 1;
}
# Don't use the cache for logged in users or recent commenters
if ($http_cookie ~* "logged_in") {
set $no_cache 1;
}
location / {
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
fastcgi_cache_bypass $no_cache;
fastcgi_no_cache $no_cache;
fastcgi_cache MYSITE;
fastcgi_cache_valid 60m;
}
http {
# memcached servers, generated according to wp-ffpc config
upstream memcached-servers {
server 127.0.0.1:11211;
}
# PHP-FPM upstream; change it accordingly to your local config!
upstream php-fpm {
server 127.0.0.1:9000;
}
server {
## Listen ports
listen 80;
listen [::]:80;
server_name %host% %aliases%;
root "%hostdir%";
# set up logging
access_log /var/log/nginx/site.access.log;
error_log /var/log/nginx/site.error.log;
# a bit of security; uncomment if you're using any WAF
## Block SQL injections
location ~union.*select.*\( { deny all; }
location ~union.*all.*select.* { deny all; }
location ~concat.*\( { deny all; }
## Block common exploits
location ~ (<|%3C).*script.*(>|%3E) { deny all; }
location ~ base64_(en|de)code\(.*\) { deny all; }
location ~ (\[|\]|\(|\)|<|>|ê|"|\;) { deny all; }
location ~ (%24&x) { deny all; }
location ~ (%0|%A|%B|%C|%D|%E|%F|127\.0) { deny all; }
location ~ \.\.\/ { deny all; }
location ~ ~$ { deny all; }
location ~ proc/self/environ { deny all; }
location ~ /\.(htaccess|htpasswd) { log_not_found off; deny all; }
## Block file injections
location ~ [a-zA-Z0-9_]=http:// { deny all; }
location ~ [a-zA-Z0-9_]=(\.\.//?)+ { deny all; }
location ~ [a-zA-Z0-9_]=/([a-z0-9_.]//?)+ { deny all; }
## more security
location ~ (licence|readme|license)\.(html|txt) { deny all; }
location ~ \.(css|js|jpg|jpeg|png|gif)$ {
expires 7d;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
add_header "Vary" "Accept-Encoding";
}
## PHP5-FPM
location ~ (\.php) {
# these settings are usually in fastcgi_params
fastcgi_index index.php;
fastcgi_connect_timeout 10;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffer_size 512k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 512k;
fastcgi_temp_file_write_size 512k;
fastcgi_intercept_errors on;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_keep_conn on;
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_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param REDIRECT_STATUS 200;
# uncomment these for HTTPS usage
#fastcgi_param HTTPS $https if_not_empty;
#fastcgi_param SSL_PROTOCOL $ssl_protocol if_not_empty;
#fastcgi_param SSL_CIPHER $ssl_cipher if_not_empty;
#fastcgi_param SSL_SESSION_ID $ssl_session_id if_not_empty;
#fastcgi_param SSL_CLIENT_VERIFY $ssl_client_verify if_not_empty;
fastcgi_pass php-fpm;
}
location / {
try_files $uri $uri/ @memcached;
}
# try to get result from memcached
location @memcached {
default_type text/html;
set $memcached_key data-$scheme://$host$request_uri;
set $memcached_request 1;
# exceptions
# avoid cache serve of POST requests
if ($request_method = POST ) {
set $memcached_request 0;
}
# avoid cache serve of admin-like pages, starting with "adm"
if ( $uri ~ "/adm/" ) {
set $memcached_request 0;
}
# may be avoid cache for logged in users
if ($http_cookie ~* "logged*" ) {
set $memcached_request 0;
}
if ( $memcached_request = 1) {
memcached_pass memcached-servers;
error_page 404 = @rewrites;
}
if ( $memcached_request = 0) {
rewrite ^ /index.php?$args last;
}
}
## rewrite rules
location @rewrites {
rewrite ^ /index.php?$args last;
}
}
}
Преимущество в более бережном отношении к оперативной памяти.factotum:суть nginx, то преимущества в тонкой настройке статики