Nginx的discuz缓存proxy cache范例和location优先级教材
  • Nginx的discuz缓存proxy cache范例

    首先将discuz的html伪静态设置好,然后用nginx缓存起来。可以将缓存时间设置为2分钟,这样可以极大的降低php请求数量,也可以较快的刷新动态内容(如新帖/回帖)

    server  {
        listen 4.3.2.1:80;
        server_name www.654z.com bbs.654z.com;


            location ~ .*/.(jpg|jpeg|css|js|gif|png|ico|txt|zip|rar|gz|mp3|wav|swf|mov|doc|pdf|xls|ppt|docx|pptx|xlsx)?$    {
                    root /home/ibcai/public_html/;
                    index index.html index.htm index.php;
            }

            location ~ .*/.(htm|html)?$    {
                    proxy_pass http://4.3.2.1:9192;
                    include vhosts/conf.proxy_cache;
            }

            location ~ /(index|forumdisplay|viewthread|space|tag)/.php?$    {
                   proxy_pass http://4.3.2.1:9192;
                    include vhosts/conf.proxy_cache;
            }

            location ~ .*/.(php|jsp|cgi|phtml)?$    {
                   proxy_pass http://4.3.2.1:9192;
                   include vhosts/conf.proxy_no_cache;
            }
    }

    nginx的location设置优先级教材:

    (location =) > (location 完整路径 >) >(location ^~ 路径) >(location ~* 正则) >(location 路径)
         只要匹配到,其它的都会忽略,然后返回到改匹配。

     

    如果都是正则,都能够匹配,以配置文件出现顺序来,谁在前谁优先。

     

  •  

  • 点这里复制本页地址发送给您QQ/MSN上的好友
  • 300*300广告