Nginx“;代理缓存;需要配置帮助
我遇到了一个非常奇怪的问题。我只想为“new site.com”启用代理缓存。然而,当这样做时,Nginx正在代理缓存我的所有网站 我已经检查了所有vhost/config文件,并确保所有“http”和“server”块都已正确打开和关闭。据我所知,只有当您在网站“服务器”块中包含(例如)“代理缓存新站点”时,才会为站点启用代理缓存 在我的“http”块中,我加载了所有的websites.conf文件,但没有一个包含任何proxy\u缓存指令 我做错了什么 以下是我的配置文件的一个片段:Nginx“;代理缓存;需要配置帮助,nginx,Nginx,我遇到了一个非常奇怪的问题。我只想为“new site.com”启用代理缓存。然而,当这样做时,Nginx正在代理缓存我的所有网站 我已经检查了所有vhost/config文件,并确保所有“http”和“server”块都已正确打开和关闭。据我所知,只有当您在网站“服务器”块中包含(例如)“代理缓存新站点”时,才会为站点启用代理缓存 在我的“http”块中,我加载了所有的websites.conf文件,但没有一个包含任何proxy\u缓存指令 我做错了什么 以下是我的配置文件的一个片段: htt
http {
...
...
# nginx cache
proxy_cache_path /www/new-site.com/httpdocs/cache levels=1:2
keys_zone=new-site:10m
max_size=50m
inactive=1440m;
proxy_temp_path /www/new-site.com/httpdocs/cache/tmp 1 2;
# virtual hosting
include /etc/nginx/vhosts/*.conf;
}
下面是我的“new site.com”vhost conf文件:
server {
listen xxx.xxx.xxx.xxx:80;
server_name new-site.com;
root /www/new-site.com/httpdocs;
index index.php;
...
...
proxy_cache new-site;
location / {
try_files $uri @backend;
}
location ~* \.php {
include /usr/local/etc/nginx/proxypass.conf;
proxy_ignore_headers Expires Cache-Control;
proxy_cache_use_stale error timeout invalid_header updating http_502;
proxy_cache_bypass $cookie_session $http_secret_header;
proxy_no_cache $cookie_session;
add_header X-Cache $upstream_cache_status;
proxy_cache_valid 200 302 5m;
proxy_cache_valid 404 1m;
proxy_pass http://127.0.0.1:80;
}
location @backend {
include /usr/local/etc/nginx/proxypass.conf;
proxy_ignore_headers Expires Cache-Control;
proxy_cache_use_stale error timeout invalid_header updating http_502;
proxy_cache_bypass $cookie_session $http_secret_header;
proxy_no_cache $cookie_session;
add_header X-Cache $upstream_cache_status;
proxy_cache_valid 200 302 5m;
proxy_cache_valid 404 1m;
proxy_pass http://127.0.0.1:80;
}
location ~* \.(jpg|jpeg|gif|png|bmp|ico|pdf|flv|swf|css|js)$ {
....
}
}
一旦我将行“proxy_cache new site;”移到“location”块中,我就解决了这个问题
不知道为什么我有这个问题,当它坐在一个街区外,虽然