`
ytfei
  • 浏览: 87248 次
社区版块
存档分类
最新评论

nginx 配置

阅读更多

 --prefix=/opt/app/nginx --with-rtsig_module --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_stub_status_module --with-http_gzip_static_module --add-module=/data/software/nginx/nginx-accesskey-2.0.3 --add-module=/data/software/nginx/ngx_cache_purge-1.2
 
 --add-module=/data/software/nginx/nginx-accesskey-2.0.3 是一个第三方模块,用于防盗链
 --add-module=/data/software/nginx/ngx_cache_purge-1.2 第三方模块,用于缓存系统
 
 
 配置参考:http://comtv.blog.51cto.com/17037/406066  nginx+tomcat 负载均衡缓存服务器集群
           http://www.yongri.info/linux/nginxconfigwebcache.html  Nginx的web缓存配置
           http://www.linuxpk.com/58314.html   nginx rewrite伪静态配置参数详细说明
 
 gzip_proxied    any;  前端是squid的情况下要加此参数,否则squid上不缓存gzip文件
 
 ------------------------------------------
 
 不使用purge时原来nginx也支持简单的缓存方案,
 
 location / {
root /home/html/;
proxy_store on;
proxy_set_header Accept-Encoding ”;
proxy_temp_path /home/tmp;
if ( !-f $request_filename )
{
proxy_pass http://www.inginx.com/;
}
}
 
 3、基于memcached的缓存

nginx对memcached有所支持,但是功能并不是特别之强,性能上还是非常之优秀。

location /mem/ {
if ( $uri ~ “^/mem/([0-9A-Za-z_]*)$” )
{
set $memcached_key “$1″;
memcached_pass 192.168.1.2:11211;
}
expires 70;
}

 

4.rewrite 的一些规则

 

rewrite ^  http://www.xxx.com$request_uri?; //可以放置在location 或server 目录下

 

参考文章:http://www.ccvita.com/348.html Nginx下Discuz!的Rewrite

 

5.proxy pass

 location /blah/ {
        proxy_pass http://backend/boom/;



    }

and request "/blah/something" your backend will see "/boom/something".

Without uri component (proxy_pass http://mongrel


) uri will be 
transfered to backend as is, i.e. for
    location /blah/ {
        proxy_pass http://backend;



    }
and request "/blah/something" your backend will see "/blah/something".



具体参考:http://typengine.com/content/nginx%E9%85%8D%E7%BD%AE%E7%BC%93%E5%AD%98cache%E7%9A%845%E7%A7%8D%E6%96%B9%E6%A1%88 nginx 5种缓存方案

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics