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

Concrete CMS ログインページに IP 制限や BASIC 認証を追加する方法

Last updated at Posted at 2019-09-04

Basic 認証

Apache な Concrete CMS (concrete5) サイトでログインページに Basic 認証を付ける方法です。

Nginx での方法はこちら
https://qiita.com/katzueno/items/b6b28d12c4105b4c133d

<Files "login">
AuthType Basic
AuthName "KatzCurry"
AuthUserFile /var/www/html/.htpasswd
Require valid-user
</Files>

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_URI} index\.php/login
RewriteRule ^index.php/(.*) $1 [R,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}/index.html !-f
RewriteCond %{REQUEST_FILENAME}/index.php !-f
RewriteRule . index.php [L]

concrete5 はドメインのルートに設置されている想定です。違う場合は、RewriteBase を書き換えてください。

/index.php/login を /login にリダイレクトさせて、

AuthUserFile /var/www/html/.htpasswd を実際の .htpasswd ファイル保存先に書き換えてください。

RewriteCond %{REQUEST_URI} index\.php/login の記述もドメインルート設置ではない場合は変更が必要です。

IP 制限

下記のように設定することで IP 制限が可能です。(未検証)

<Files "login">
	<RequireAny>
		Require ip xxx.xxx.xxx.xxx
		Require ip xxx.xxx.xxx.xxx
	</RequireAny>
</Files>

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_URI} index\.php/login
RewriteRule ^index.php/(.*) $1 [R,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}/index.html !-f
RewriteCond %{REQUEST_FILENAME}/index.php !-f
RewriteRule . index.php [L]

IP 制限といっても、AWS の ELB だったり、さくらのレンタルサーバーなどではプロキシサーバーがあるので特殊な設定が必要です。詳細は僕の別の Qiita の記事にて。
https://qiita.com/katzueno/items/4cf15117d228dbaf2448

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