如何解决nginx 中端点的缓存版本
我想要使用 nginx 缓存的 API 端点的替代网址。例如,网址 /cached/api/songs/latest
应返回来自 PHP 引擎的端点 /api/songs/latest
的缓存版本。
我想出了这个配置,但它不起作用。你能告诉我我做错了什么吗?
proxy_cache_path /data/cache/nginx keys_zone=one:10m loader_threshold=300
loader_files=200 max_size=200m;
server {
server_name api.myserver.com;
# SSL configuration
listen 443 ssl;
ssl_certificate ...
ssl_certificate_key ...
root /data/myapp/public;
index index.html index.php;
# cached version of the endpoints
location ~ ^/cached/.*$ {
rewrite ^/cached(.*)$ /$1 break;
proxy_pass https://127.0.0.1:443;
proxy_cache_valid any 60m;
}
# standard includes
include global/restrictions.conf;
include global/common_php.conf;
include global/static_assets.conf;
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。