nginxサーバの設定についてまとめ

サンプルコード
if (!-e $request_filename) {
proxy_pass http://sample.com;
}

if ($http_user_agent ~ MSIE) {
rewrite ^(.*)$ /nginx-ie/$1 break;
}

location ~* \.(gif|jpg|png|swf|flv|swf)$ {
valid_referers none blocked www.sample.com sample.com;
if ( $invalid_referer ) {
rewrite ^/ http://$host/logo.png;
}
}

//有効期間
location ~* \.(js|css|jpg|jpeg|gif|png|swf)$ {
if ( -f $request_filename ) {
expires 1h;
break;
}
}

//ディレクトリアクセス禁止
location ~* \.(txt|doc)${
root /data/www/wwwroot/linuxtone/test;
deny all;
}

Nginx

Posted by arkgame