nginx

обновление nginx на debian 6 squeeze

1.Добавляем ключи

gpg --keyserver hkp://keys.gnupg.net --recv-keys ABF5BD827BD9BF62
gpg -a --export 7BD9BF62 | apt-key add -

2.Добавляем репы
deb <a href="http://nginx.org/packages/debian/" title="http://nginx.org/packages/debian/">http://nginx.org/packages/debian/</a> squeeze nginx >> /etc/apt/source.list
deb-src <a href="http://nginx.org/packages/debian/" title="http://nginx.org/packages/debian/">http://nginx.org/packages/debian/</a> squeeze nginx >> /etc/apt/source.list

3.Устанавливаем nginx
apt-get update
apt-get install nginx

504 Gateway Time-out

nginx anti-ddos

if ($cookie_antiflood !~* "что-нибудь") {
    rewrite ^(.*)$ /set_cookie$1 permanent;
    break ;
}
location ~ ^/set_cookie/ {
    add_header Set-Cookie "antiflood=что-нибудь; path=/";
    rewrite ^/set_cookie/(.*)$ /$1 permanent;
    break ;
}

http://habrahabr.ru/blogs/infosecurity/128526/#comment_4251423

nginx status

active connections -- number of all open connections including connections to backends

reading -- nginx reads request header

writing -- nginx reads request body, processes request, or writes response to a client

waiting -- keep-alive connections, actually it is ( active - (reading + writing) )

nginx proxy_cache для отдельных запросов

http {
 
proxy_cache_path  /var/cache/nginx/cacheone levels=1:2 keys_zone=cacheone:20m max_size=1024m;
 
...
}
 
server {
 
    ...
 
    set $mykey "";
 
    location ... {
         if ($query_string ~ "(foo.*)")
         {
             set $mykey $1;
             error_page 404  =  @cacheone;
             return 404;
         }
 
        ...
    }
 
    location @cacheone {
        proxy_cache cacheone;
        proxy_cache_key "$request_method|$http_if_modified_since|$http_if_none_match|$mykey";
        proxy_cache_valid 200 301 302 304 7m;

nginx: ограничение количества одновременных подключений на vhost

http {
limit_zone client $server_name 10m;
limit_conn client 20;