2017-11-20 12 views
0

두 개의 다른 포트 (3636, 4646)에 두 개의 Node.js 서버가 있고, Nginx 웹 서버를 내 서버의 역방향 프록시로 사용하고 있습니다. 내 문제는 Varnish를 추가하는 방법입니다. 두 서버 모두에 캐시 도구가 있습니까?Node.js 및 Nginx와 함께 Varnish 캐시 도구 사용

을/etc/nginx를/사이트 사용/사용자 도메인 :

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

입니다? varnish default.vcl에서 볼 수 없으며 다른 모든 default.vcl 파일 행은 표시된 행을 제외하고 주석 처리됩니다. – Arman

+0

기본 .vcl 구성 안에 있습니다. 그게 네가 nginx 호스트와 포트 (백엔드) 캐시에 바니시 가리킨다. [link] (https://varnish-cache.org/docs/trunk/users-guide/command-line.html)에 따라'-b localhost : 8080'을 추가하는 명령 행에서도 할 수 있습니다 – egnd09

+0

백엔드 기본값 올바른 vcl_deliver 하위 비어 있습니다. – Arman