Nginx의 Proxy cache(cache_purge module)를 사용하여 공유 메모리를 사용하려니 아래와 같은 오류 메세지가 떴습니다.

[root@yongbok ~]# nginx -t
nginx: [emerg] the size 10485760 of shared memory zone “tmpcache” conflicts with already declared size 0 in /usr/local/etc/nginx/nginx.conf:96

 

이 경우는 proxy_cache_path 가 proxy_pass 보다 뒤에 있을때 발생합니다.

proxy_pass http://127.0.0.1:8000;
proxy_cache_path /tmp/cache levels=1:2 keys_zone=tmpcache:10m inactive=30m max_size=2g;

[root@yongbok ~]# nginx -t
nginx: [emerg] the size 10485760 of shared memory zone “tmpcache” conflicts with already declared size 0 in /usr/local/etc/nginx/nginx.conf:96

 

그러므로 proxy_cache_path 다음으로 proxy_pass가 와야 오류가 발생하지 않습니다.

proxy_cache_path /tmp/cache levels=1:2 keys_zone=tmpcache:10m inactive=30m max_size=2g;
proxy_pass http://127.0.0.1:8000;

[root@yongbok ~]# nginx -t
nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful

참고
http://forum.nginx.org/read.php?2,9716,9905