Varnish www to non-www 넘겨주기

Jmnote (토론 | 기여)님의 2018년 7월 17일 (화) 07:22 판 (Jmnote님이 Varnish www도메인 넘겨주기 문서를 Varnish www→비www 넘겨주기 문서로 이동했습니다)

1 개요

how to redirect from www to non-www varnish
Varnish www도메인 넘겨주기
sub vcl_recv {
    if (req.http.host ~ "^www\.") {
        set req.http.location = regsub(req.http.host, "^www\.(.*)", "https://\1");
        return (synth(750, "Moved Permanently"));
    }
}
sub vcl_synth {
    if (resp.status == 750) {
        set resp.http.location = req.http.location;
        set resp.status = 301;
        return (deliver);
    }
}
sub vcl_recv {
    if (req.http.host == "www.example.com") {
        set req.http.location = "https://example.com" + req.url;
        return (synth(750, "Moved Permanently"));
    }
}
sub vcl_synth {
    if (resp.status == 750) {
        set resp.http.location = req.http.location;
        set resp.status = 301;
        return (deliver);
    }
}

2 같이 보기

3 참고

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}