2017-11-20 3 views
0

2つの異なるポート(3636,4646)に2つのNode.jsサーバーがあり、Nginx Webサーバーをサーバーのリバースプロキシとして使用しています。私の問題はワニスを追加する方法です両方のサーバーにキャッシュツールをインストールしますか?Node.jsとNginxでワニスキャッシュツールを使用

の/ etc/nginxの/サイト対応/ YOURDOMAIN:

upstream app_yourdomain { 
    server 127.0.0.1:3636; 
    keepalive 8; 
} 

server { 
    listen 0.0.0.0:8080; 
    server_name yourdomain.com yourdomain; 
    access_log /var/log/nginx/yourdomain.log; 
    # pass the request to the node.js server with the correct headers 
    # and much more can be added, see nginx config options 
    location/{ 
     proxy_set_header X-Real-IP $remote_addr; 
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
     proxy_set_header Host $http_host; 
     proxy_set_header X-NginX-Proxy true; 

     proxy_pass http://app_yourdomain/; 
     proxy_redirect off; 
     proxy_http_version 1.1; 
     proxy_set_header Upgrade $http_upgrade; 
     proxy_set_header Connection "upgrade"; 
    } 
} 

の/ etc/nginxの/サイト対応/ドメイン2:

server { 
    listen 8080; 
    server_name domain2.com; 
    access_log /var/log/nginx/domain2.access.log; 
    location/{ 
     proxy_pass http://127.0.0.1:4646/; 
    } 
} 

ワニスの設定ファイル:

DAEMON_OPTS="-a :80 \ 
      -T localhost:6082 \ 
      -f /etc/varnish/default.vcl \ 
      -S /etc/varnish/secret \ 
      -s malloc,256m" 

ですが、curl -I http://localhostを使用した場合、ニスの兆候はありません:

HTTP/1.1 200 OK 
Server: nginx/1.10.3 (Ubuntu) 
Date: Mon, 20 Nov 2017 12:22:17 GMT 
Content-Type: text/html 
Content-Length: 612 
Last-Modified: Mon, 18 Sep 2017 06:18:46 GMT 
Connection: keep-alive 
ETag: "59bf6546-264" 
Accept-Ranges: bytes 

/etc/varnish/default.vcl:

backend default { 
    .host = "127.0.0.1"; 
    .port = "8080"; 
} 

私が行方不明です何がありますか?

答えて

0

あなたのdefault.vclが見えないと、それは分かりません。 たぶん、あなたはこのようなものがあります:

sub vcl_deliver { 
    unset resp.http.Via; 
    unset resp.http.X-Varnish; 
}  

また、正しいバックエンドの設定を持っていることを確認してください。

backend default { 
    .host = "localhost"; 
    .port = "8080"; 
} 
+0

どこバックエンドの設定があるの?私はワニスdefault.vclでそれを見ることができません、そして、他のすべてのdefault.vclファイル行は、示された行を除いてコメントされています。 – Arman

+0

デフォルトの.vcl設定の内部にあります。 Thatsは、nginxホストとポート(バックエンド)をキャッシュするためのニスを指しています。コマンドラインで[link](https://varnish-cache.org/docs/trunk/users-guide/command-line.html)に従って '-b localhost:8080'を追加することもできます。 – egnd09

+0

バックエンドのデフォルトvcl_deliverが空です。 – Arman

関連する問題