Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
Use try_files if it suits your needs. Use the «return ...» or «rewrite… last» in other cases. In some cases it's also possible to move ifs to server level (where it's safe as only other rewrite module directives are allowed within it).
server {
listen 127.0.0.1:80;
server_name nocache.domain.tld;
location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|js|swf|txt|ico)$ {
allow 127.0.0.1;
deny all;
root /path/to/fuse/filesystem;
}
}
server {
listen 80;
server_name domain.tld
location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|js|swf|txt|ico)$ {
proxy_cache static_cache;
proxy_cache_valid 200 1y;
proxy_set_header Host nocache.$host;
proxy_pass http://127.0.0.1;
}
}
allow 127.0.0.1;
deny all;
internal;
perl_set $md5 '
use Digest::MD5 qw(md5_hex);
sub {
my $r = shift;
my $some_var = $r->variable("some_var");
return md5_hex($some_var);
}
';
server {
listen 8081;
location / {
set $some_var $arg_text;
return 200 $md5;
}
}
^.+\.(jpg|jpeg|gif|png|ico|css|js|swf|txt|ico)$, почему бы хотя бы для статьи не поправить очевидные косяки? И так много у вас ico на сервере (аж дважды в регулярке встречается)?location ~* \.(?:jpe?g|gif|png|ico|css|js|swf|txt)$ { .. }
location ~* \.(?!php)
location ~* \.(?!php|html|shtml) {
root xxx;
}
location ~* ^(?!.*\.(?:php|s?html)) {
root xxx;
}
server {
listen 80;
server_name xxx;
charset utf-8;
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
location ~ /\.ht {
deny all;
}
location ~* ^(?!.*\.(?:php|s?html)) {
root W:\www;
}
location / {
proxy_pass http://127.0.0.1:8080/;
proxy_set_header X-REQUEST_URI $request_uri;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-for $remote_addr;
proxy_set_header Host $host;
proxy_connect_timeout 10;
proxy_send_timeout 15;
proxy_read_timeout 15;
proxy_redirect off;
proxy_set_header Connection close;
proxy_pass_header Content-Type;
proxy_pass_header Content-Disposition;
proxy_pass_header Content-Length;
}
}
Кешируем статику