我正在尝试使用 nginx.conf 文件实现nginx-cache 。我已经从这里引用了代码
对此,我正在使用proxy_cache_
上游。
如果我使用proxy_cache_指令,以下是我面临的错误。(我已经评论了其他 proxy_cache 指令并且只使用proxy_cache_revalidate所以我得到以下错误)
我将 Nginx 作为 Docker 容器运行。(不确定,如果这是我遇到这些错误的原因)
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
下面是我的conf文件。
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;
}
}
}
请让我知道我需要在我的 conf 文件中进行哪些更改。