1
0

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.

ローカル通信以外を https に転送する

1
Posted at

概要

単なる備忘録.Apache への通信を https 強制にしたい.その一方で,サーバ内の通信はわざわざ https にする必要がないため http を使いたい.そこで,mod_rewrite を使ってアクセス元を見て https に転送するか決定する.

設定ファイル

<VirtualHost *:80>
    ServerName http://sample.com

    RewriteEngine On
    RewriteCond %{REMOTE_ADDR} !=127.0.0.1
    RewriteCond %{REMOTE_ADDR} !=%{SERVER_ADDR}
    # Docker コンテナからのアクセス
    RewriteCond %{REMOTE_ADDR} !^172\.17\.
    RewriteRule ^/?(.*)$ https://sample.com/$1
</VirtualHost>

参考

1
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?