gpt4 book ai didi

nginx 错误 - 此处不允许使用 "proxy_cache_path"指令

转载 作者:行者123 更新时间:2023-12-04 02:56:49 24 4
gpt4 key购买 nike

当我尝试在 CentOs 7.5 上启动 nginx 时,我在启用站点的 nginx.conf 中遇到以下错误。

[root@centos-linux sites-enabled]# nginx -s reload nginx: [emerg] "proxy_cache_path" directive is not allowed here in /etc/nginx/sites-enabled/ckan_default:1

proxy_cache_path /tmp/nginx_cache levels=1:2 keys_zone=cache:30m max_size=250m;
proxy_temp_path /tmp/nginx_proxy 1 2;

server {
client_max_body_size 100M;
location / {
proxy_pass http://127.0.0.1:8080/;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_cache cache;
proxy_cache_bypass $cookie_auth_tkt;
proxy_no_cache $cookie_auth_tkt;
proxy_cache_valid 30m;
proxy_cache_key $host$scheme$proxy_host$request_uri;
# In emergency comment out line to force caching
# proxy_ignore_headers X-Accel-Expires Expires Cache-Control;
}

}

不确定它在提示什么,因为这适用于 ubuntu 设置。

有人有想法吗?

最佳答案

我解决了它,看起来我不得不将整个模板封装在 http {} 中:

http {
proxy_cache_path /tmp/nginx_cache levels=1:2 keys_zone=cache:30m max_size=250m;
proxy_temp_path /tmp/nginx_proxy 1 2;

server {
client_max_body_size 100M;
location / {
proxy_pass http://127.0.0.1:8080/;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_cache cache;
proxy_cache_bypass $cookie_auth_tkt;
proxy_no_cache $cookie_auth_tkt;
proxy_cache_valid 30m;
proxy_cache_key $host$scheme$proxy_host$request_uri;
# In emergency comment out line to force caching
# proxy_ignore_headers X-Accel-Expires Expires Cache-Control;
}

}
}

关于nginx 错误 - 此处不允许使用 "proxy_cache_path"指令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52766417/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com