Nginx proxy_cache不适用于laravel

时间:2018-08-15 16:03:57

标签: laravel nginx proxy

我正在使用laravel一段时间,并且我有一个宁静的api需要nginx proxy_cache,配置文件是自爆

http{


proxy_cache_path /data/cache keys_zone=one:10m loader_threshold=300 loader_files=200;

server {
listen 80;

root /home/www-data/htdocs/a-laravel-project/public;
index index.php index.html index.htm;


server_name p.com;

location / {
    try_files $uri $uri/ /index.php?$query_string;
}

location ~ \.php$ {
    try_files $uri /index.php =404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/run/php/php7.2-fpm-admin.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
}
location /get-weather{
    proxy_cache one;
    proxy_cache_key $host$uri$is_args$args;
    proxy_cache_valid 200 10m;
    add_header  Nginx-Cache "$upstream_cache_status";

    try_files $uri /index.php =404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/run/php/php7.2-fpm-admin.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;

}

...
}

...

}

当我卷曲此URL(http://p.com/get-weather)时,它没有返回Nginx缓存,我认为这是因为/ get-weather被重写为index.php / get-weather

0 个答案:

没有答案