I am trying to implement nginx-cache using nginx.conf file. I have referred the code from here
Regards to that, I am using proxy_cache_
upstream.
Below is the error that I am facing if I use proxy_cache_ directive. (I have commented other proxy_cache directive and just use proxy_cache_revalidate so I get below error)
I am running Nginx as a Docker container. (Not sure, if this is the reason why I am encountering these errors)
2018/10/16 04:23:39 [emerg] 1#1: unknown directive "proxy_cache_revalidate on" in /etc/nginx/nginx.conf:127
nginx: [emerg] unknown directive "proxy_cache_revalidate on" in /etc/nginx/nginx.conf:127
Below is my conf file.
thread_pool default threads=32 max_queue=65536;
events { worker_connections 102400; }
http {
sendfile on;
sendfile_max_chunk 2048k;
access_log off;
#Implementing NGINX Cache
proxy_cache_path /usr/nginx-cache levels=1:2 keys_zone=nginx_cache:10m max_size=10g inactive=60m use_temp_path=off;
upstream licenseportal {
server xx.xx.xx.xx:9006;
}
upstream publisherportal {
server xx.xx.xx.xx:9001;
}
upstream supportportal {
server xx.xx.xx.xx:9010;
}
server {
listen 8765;
location /licenseportal/ {
proxy_pass http://licenseportal/;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
#Implementing NGINX Cache
proxy_cache nginx_cache;
proxy_cache_revalidate on;
#proxy_cache_min_uses 3;
#proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
#proxy_cache_background_update on;
#proxy_cache_lock on;
#proxy_cache_methods GET;
}
location /publisherportal/ {
proxy_pass http://publisherportal/;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
# #timeout setting added
fastcgi_read_timeout 7200s;
send_timeout 7200s;
proxy_connect_timeout 7200s;
proxy_send_timeout 7200s;
proxy_read_timeout 7200s;
#new property added
proxy_request_buffering off;
proxy_buffering off;
#Implementing NGINX Cache
proxy_cache nginx_cache;
#proxy_cache_revalidate on;
#proxy_cache_min_uses 3;
#proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
#proxy_cache_background_update on;
#proxy_cache_lock on;
#proxy_cache_methods GET;
}
location /supportportal/ {
proxy_pass http://supportportal/;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
#Implementing NGINX Cache
proxy_cache nginx_cache;
#proxy_cache_revalidate on;
#proxy_cache_min_uses 3;
#proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
#proxy_cache_background_update on;
#proxy_cache_lock on;
#proxy_cache_methods GET;
}
}
}
Please let me know what changes I need to do in my conf file.