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 3 years have passed since last update.

<lightsail>cloudfrontからのみアクセスを許容したい

1
Posted at

lightsailはサクッとサーバーを立てれて良いですよね。
今回は、lightsailに乗っけたwordpressのアクセスをcloudfrontのみにしたいなという時のまとめです。

つまり、ipとかlightsail自体のドメインへのアクセスを拒否したいということですね。

方法

cloudfrontからのアクセスを証明するヘッダーを持たせて、それ以外の場合に拒否しようと思います。

cloudfront側

オリジンを編集から
適当なヘッダーを持たせてください。
今回はX-Custom-Headerにhogefugapiyoを持たせています。

スクリーンショット 2023-06-25 1.55.48.png

lightsail側

Apache サーバーの処理を変えていく
bitnami使っている場合はこちらのパスにある
/opt/bitnami/apache2/conf/vhosts/wordpress-vhost.conf

<Directory "/opt/bitnami/wordpress">
# 追加!
SetEnvIf X-Custom-Header "hogefugapiyo" allow_custom
    Require env allow_custom
</Directory>

これでX-Custom-Header: hogefugapiyoを持たないアクセスはforbiddenになります!

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?