【问题标题】:How make a nginx cache like a varnish?如何使 nginx 缓存像清漆一样?
【发布时间】:2017-06-30 02:10:09
【问题描述】:

我在 heroku 中托管一个网站,并在云主机中使用 nginx 作为代理。

在我的云主机中,我定义了这个:

## /etc/nginx/sites-available/default
server {
charset utf-8;
listen 80;

server_name mywebsite.com www.mywebsite.com;

location /api {
    proxy_pass http://mywebsite-api.herokuapp.com;
}

location /auth {
    proxy_pass http://mywebsite-api.herokuapp.com;
}

location / {
    fastcgi_cache CACHE_KEY;
    fastcgi_cache_valid 200 60m;

    proxy_pass http://mywebsite-fe.herokuapp.com;
}
}

## in /etc/nginx/nginx.conf
.......
http {

  fastcgi_cache_path /etc/nginx/cache levels=1:2 keys_zone=CACHE_KEY:100m inactive=60m;
  fastcgi_cache_key "$scheme$request_method$host$request_uri";
  .....

我想在 nginx 中制作静态内容,比如清漆。如何使用带有 Heroku 代理的 nginx 来做到这一点?

谢谢。

【问题讨论】:

    标签: caching nginx heroku proxy


    【解决方案1】:

    将 fastcgi_ 更改为 proxy_。 fastcgi_ 版本适用于 php-fpm。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-12-07
      • 2014-04-07
      • 2018-04-07
      • 2012-04-03
      • 2017-01-09
      • 1970-01-01
      • 1970-01-01
      • 2016-05-25
      相关资源
      最近更新 更多