2013年6月16日日曜日

VarnishでHTTPのアクセス(S3)をHTTPSのアクセス(S3)にリダイレクト

スズキです。

以前紹介した下記の合わせ技です。

概要は、こんな感じです。



設定ファイル(/etc/varnish/default.vcl)は、こんな感じです。
backend default {
    .host = "localhost";
    .port = "80";
}

sub vcl_recv {
    if(req.http.host == "www.suz-lab.com") {
        if(req.http.X-Forwarded-Proto == "https") {
            set req.backend   = suzlab;
            set req.http.host = "www.suz-lab.com.s3-website-ap-northeast-1.amazonaws.com";
            set req.request   = "GET";
            return(lookup);
        }
    }
    return(error);
}

sub vcl_error {
    if(req.http.host == "www.suz-lab.com") {
        if(req.http.X-Forwarded-Proto != "https") {
            set obj.http.Location = "https://" req.http.host req.url;
            set obj.status = 301;
        }
    }
    return(deliver);
}

backend suzlab {
    .host = "www.suz-lab.com.s3-website-ap-northeast-1.amazonaws.com";
    .port = "80";
}

今回、SSLターミネーションはELBで実施していますが、近頃リリースされた下記の
CloudFrontでのターミネーションの方が、今後はいいかもしれません。(未検証)
Amazon CloudFrontが独自SSL証明書とルートドメインホスティングをサポート

6月初ブログ...(俺は今まで何をしてたんだろう...)
--------
http://www.suz-lab.com

3 コメント:

匿名 さんのコメント...

Attractive section of content. I simply stumbled upon your website
and in accession capital to say that I get actually enjoyed account your weblog posts.
Any way I will be subscribing to your augment or even
I achievement you get admission to constantly rapidly.


Also visit my web site - damp cigaret

匿名 さんのコメント...

The latter in the helped me constantly rethink tips on how to keep my opportunity afloat.
In 1399 Richard II seized the castle from your 2nd Duke of
Lancaster, John of Gaunt after his death and claimed the castle within the name with the
monarchy. Make sure i hear you ask concerning the genetic backgrounds in the parents,
any health guarantees offered and which initial healthcare measures are going to be included (shots, worming, etc.
Don't rearrange furniture from the house if it is possible to avoid it. You can make money from 5 cents to a number of hundred thousand dollars per month.

Check out my web site; English Bulldog Puppies

匿名 さんのコメント...

Howdy! This post couldn't be written any better! Reading through this article reminds me of my previous roommate! He always kept talking about this. I'll send this information to him.

Pretty sure he'll have a very good read. Thanks for sharing!

Look into my web site ... online seo training course