nginx反向代理并缓存配置

配置如下:

proxy_temp_path   /mnt/xxx;  
proxy_cache_path  /mnt/xxx/cache levels=1:2 keys_zone=home_one:50m inactive=1d max_size=10g;  
server  {  
        listen          80;
        server_name  www.xxx.com xxx.com;
    if ( $host = 'xxx.com' ) {   rewrite ^(.*) http://www.xxx.com; }

        location / {
                proxy_pass          http://cache.xxx.com; #反代的网站
                proxy_redirect          off;
                proxy_set_header        X-Real-IP       $remote_addr;
                proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;

                proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504 http_404;

                client_max_body_size       10m;
                client_body_buffer_size    128k;

                proxy_connect_timeout      90;
                proxy_send_timeout         90;
                proxy_read_timeout         90;

                #开启反向代理缓存,并使用keys_zone name为home_one的缓存。
                proxy_cache home_one; 
                #设置状态码为200 302过期时间为2小时
                proxy_cache_valid 200 302 2h; 
                #设置状态码301的过期时间为1天
                proxy_cache_valid 301 1d; 
                proxy_cache_valid any 1h; 

                proxy_buffer_size          4k;
                proxy_buffers              4 32k;
                proxy_busy_buffers_size    64k;
                proxy_temp_file_write_size 64k;

        }
}

proxy_temp_path 和proxy_cache_path不能设置为一样,否则报错:

Starting nginx: nginx: [emerg] the same path name "/mnt/xxx" used in ....