2013-08-28 1 views
0

다음과 같은 구성이 있습니다. 하지만 응용 프로그램에 액세스하면 로그인을 요구하지 않고 로그인 만합니다. 내가 뭘 잘못하고있어?Rails 응용 프로그램 용 Nginx로 바니시 (Devise 인증 관련 문제)

default.vcl

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


sub vcl_recv { 
    if(req.url ~ "sign_in" || req.url ~ "sign_out" || req.request == "POST" || req.request == "PUT" || req.request == "DELETE") { 
    return (pass); 
    } 
    return (lookup); 
} 

sub vcl_fetch { 
if(req.url ~ "logout" || req.url ~ "sign_out"){ 
    unset beresp.http.Set-Cookie; 
} 
if (req.request == "GET") { 
     unset beresp.http.Set-Cookie; 
     set beresp.ttl = 360m; 
} 

if (req.url ~ "images/" || req.url ~ "javascripts" || req.url ~ "stylesheets" || req.url ~ "assets"){ 
     set beresp.ttl = 360m; 
} 
} 

은/etc/기본/니스

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

을/etc/nginx를/사이트 사용/기본

upstream app { 
    server unix:/tmp/unicorn.socket fail_timeout=0; 
} 

server { 
listen 80; 
client_max_body_size 2G; 
server_name localhost; 
keepalive_timeout 5; 
root /home/deploy/apps/wms/current/public; 
access_log off; 
error_log off; 

if ($request_method !~ ^(GET|HEAD|PUT|POST|DELETE|OPTIONS)$){ 
    return 405; 
} 

location ~ ^/(assets)/ { 
    gzip_static on; 
    expires  max; 
    add_header Cache-Control public; 
} 

location/{ 
    try_files $uri/index.html $uri.html $uri @app; 
    error_page 404    /404.html; 
    error_page 422    /422.html; 
    error_page 500 502 503 504 /500.html; 
    error_page 403    /403.html; 
} 

location @app { 
    proxy_pass http://app; 
} 

location = /favicon.ico { 
    expires max; 
    add_header Cache-Control public; 
} 

location ~ \.php$ { 
    deny all; 
} 

} 

답변

1

당신은 당신의 백엔드를 방해하는 세션 쿠키를 삭제하십시오. 따라서 브라우저의 쿠키를 명시 적으로 삭제하지 않으면 로그 아웃 할 수 없습니다.

당신의 VCL을 가져 오기 (코멘트 인라인)에서 상대 :

sub vcl_fetch { 
    # This prevents server from deleting the cookie in the browser when loging out 
    if(req.url ~ "logout" || req.url ~ "sign_out"){ 
    unset beresp.http.Set-Cookie; 
    } 
    if (req.request == "GET") { 
    unset beresp.http.Set-Cookie; 
    set beresp.ttl = 360m; 
    } 
    if (req.url ~ "images/" || req.url ~ "javascripts" || req.url ~ "stylesheets" || req.url ~ "assets"){ 
    set beresp.ttl = 360m; 
    } 
} 

그래서 당신의 백엔드하지 않는 POST 요청의 결과로 클라이언트의 쿠키를 삭제할 수 없습니다.

이럴 당신이해야 백엔드의 설정 - 쿠키 헤더가 엉망 당신이 알고있는 (잘 테스트) 추적 할 수없는 가망 부작용

+0

나는 니스에 새로 온 사람을 제외하고. 그 줄을 제거해야합니까? 어떻게해야합니까? –

+0

첫 번째 if 블록을 제거/주석 처리하고 바니시를 다시로드/다시 시작하면 – NITEMAN

+0

Worked라는 문제를 피할 수 있다고 확신합니다. 나는 두 개의 블록을 제거하고 그것은 매력처럼 작동했습니다. –