1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

24時間ごとにhttp→httpsへのリンク変更を促すサイトの設定

Posted at

www.e-Gov.go.jp のhttps化が話題となっていますが、

  • http→httpsの変更だけでパスが同じならリダイレクトして欲しい
  • リダイレクトするといつまで経ってもリンクやブックマークが修正されない

といったあたりで平行線になっているように感じられます。

そこで「24時間おきにhttp→httpsへのリンク変更を促す」という(ちょっとうざい)設定ができないか試してみました。

設定と解説

<VirtualHost *:80>
    :
   RewriteEngine on
   RewriteRule ^(.*)$ https://%{HTTP_HOST}/sorry.html [R=303,L]
</VirtualHost>

<VirtualHost *:443>
    :
   <Location "/sorry.html">
      Header set Strict-Transport-Security "max-age=86400;"
      FileEtag None
      RequestHeader unset If-Modified-Since
      Header set Cache-Control no-store
   </Location>
</VirtualHost>
  • httpへのアクセスでは常にhttps://.../sorry.htmlにリダイレクトする(303は妥当?)
  • https://.../sorry.htmlへのアクセスに対して、
  • Strict-Transport-Securityを86400秒(24時間)で返す
  • '304 Not modified'応答にはHSTSヘッダが付かないので対策する

以上。なんですが、検証していて、

  • MaxOS MojaveのSafari(12.1.1)だとページ毎にしかHSTSが効かないっぽい
  • Windows 10のEdgeだとブラウザを閉じるまでHSTSが効き続ける
  • Chrome, Firefoxは両OSで期待通りの動きになる

というなかなか興味深い挙動が確認できました。

採用したら500円ください(懐かしいお名前を拝見しました)

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?