簡體   English   中英

如何使Nginx緩存像清漆一樣?

[英]How make a nginx cache like a varnish?

我在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做到這一點?

謝謝你

將fastcgi_更改為proxy_。 fastcgi_版本適用於php-fpm。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM