nginx proxy_cache配置后不生成缓存文件,也不缓存图片,且css,js等报500

u012914916 2014-11-12 03:12:47
实在是搞不好了,,求帮助。。。
nginx.conf

http {
#cache begin
proxy_buffering on;
proxy_cache_valid any 10m;
proxy_cache_path /data/cache levels=1:2 keys_zone=my-cache:8m max_size=1000m inactive=600m;
proxy_temp_path /data/temp;
proxy_buffer_size 4k;
proxy_buffers 100 8k;
#cache end

upstream upserver {
server 104.149.128.130;
}
include /etc/nginx/conf.d/*.conf;
}

conf.d/default.conf

server {
listen 80;
server_name localhost;

location / {
root /var/www/html;
index index.php index.html index.htm;
if (-e $request_filename) {
break;
}
if (!-e $request_filename) {
rewrite ^/(.*)?$ /index.php/$1 last;
break;
}
proxy_pass http://upserver;
proxy_next_upstream http_502 http_504 error timeout invalid_header;
proxy_cache my-cache;
proxy_cache_valid 200 304 12h;
proxy_cache_key $host$uri$is_args$args;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
add_header X-Cache '$upstream_cache_status from $host';
expires 1d;
}
location ~ .+\.php($|/) {
root /var/www/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_connect_timeout 300;
fastcgi_read_timeout 300;
fastcgi_send_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 32k;
fastcgi_busy_buffers_size 64k;
fastcgi_temp_file_write_size 64k;
include fastcgi_params;
}
location ~ .+\.(php|jsp+cgi) {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_pass http://upserver;
}
# location ~ \.(htm|html|gif|jpg|jpeg|png|bmp|ico|css|js)$ {
# root /var/www/html/static;
# expires 48h;
# }
# location ~ \.(txt)$ {
# root /var/www/html/data/html;
# expires 24h;
# }

}
...全文
492 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
u012914916 2014-11-12
  • 打赏
  • 举报
回复
nginx的执行用户和组: user nginx nginx;
u012914916 2014-11-12
  • 打赏
  • 举报
回复
我重启nginx,会在/data下生成temp和cache文件夹,所有者和组以及权限我都改为了nginx:nginx 777。 但是还是不会再temp和cache文件夹下生成缓存文件,而且我这样配置后css和js文件会报500。 当然配置proxy_cache前是正常的。

24,923

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Apache
社区管理员
  • Apache
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧