Apache2.4에서 테스트 환경을 구축하는 이야기
소개
안녕하세요, 하루카입니다.
개발 환경에 AWS를 사용하고 있습니다.
테스트 환경으로 이행했을 때 사외의 사람에게 보이고 싶지 않다. . .
라고 생각했으므로, 메모로서 둘 때입니다.
전제
저는 AWS 초보자이므로 Amazon Linux 2 AMI(HVM), SSD Volume Type을 사용하고 있습니다.
목차
1.ip 제한을 걸기
2.Basic 인증 도입
3.ip 제한, Basic 인증 병용
ip 제한을 걸다
httpd.conf
<Directory "/var/www/html">
...
# Require all granted #ここのコメントをオンにすると全体から閲覧できるようになります。
Require ip XXX.XXX.XX.X #IPアドレスを挿入します。
...
</Directory>
이 방법은 가장 간단합니다.
자사의 사람이라면 누구라도 봐 좋다-라고 때는 이 방법으로 좋다고 생각합니다.
기본 인증 도입
소개 htpasswd가 존재하는지 확인. . .
[ec2-user@プライベートip]$htpasswd
Usage:
htpasswd [-cimBdpsDv] [-C cost] passwordfile username
htpasswd -b[cmBdpsDv] [-C cost] passwordfile username password
htpasswd -n[imBdps] [-C cost] username
htpasswd -nb[mBdps] [-C cost] username password
-c Create a new file.
-n Don't update file; display results on stdout.
-b Use the password from the command line rather than prompting for it.
-i Read password from stdin without verification (for script usage).
-m Force MD5 encryption of the password (default).
-B Force bcrypt encryption of the password (very secure).
-C Set the computing time used for the bcrypt algorithm
(higher is more secure but slower, default: 5, valid: 4 to 17).
-d Force CRYPT encryption of the password (8 chars max, insecure).
-s Force SHA encryption of the password (insecure).
-p Do not encrypt the password (plaintext, insecure).
-D Delete the specified user.
-v Verify password for the specified user.
On other systems than Windows and NetWare the '-p' flag will probably not work.
The SHA algorithm does not use a salt and is less secure than the MD5 algorithm.
존재하지 않으면 ↓ 링크를 참조하여 install하십시오.
htp : //타니히로. 하테나 bぉg. 코m/엔트리/2014/02/05/172938
다음
$ cd /etc/httpd/conf #このコマンドでconf階層まで必ず移動してください
$sudo htpasswd -c <filepass名> <username>
New password: パスワード入力
Re-type new password: パスワード再入力
Adding password for user <username>
그리고는 아래와 같이 Directory에 Basic 인증 조건을 기입합니다.
httpd.conf
<Directory "/var/www/html">
...
AuthType Basic
AuthName "Basic Auth"
AuthUserFile /etc/httpd/conf/.htpasswd
Require valid-user
...
</Directory>
지금까지 설정이 끝나면 apache를 다시 시작하십시오.
이런 화면이 나오면 성공입니다!
ip 제한, Basic 인증 병용
httpd.conf
<Directory "/var/www/html">
...
<RequireAll>
Require ip 自分のIPアドレス
<RequireAny>
AuthType Basic
AuthName "適当なコメント"
AuthUserFile /etc/httpd/conf/<ファイル名>
Require valid-user
</RequireAny>
</RequireAll>
・・・
</Directory>
위와 같이 설정하면 IP 주소가 다른 사용자는 사이트에 들어갈 수 없습니다.
만일 IP 주소가 일치했을 경우도 Basic 인증이 작동합니다.
확실히 개발자 이외의 사람이 들어가 데이터를 지워 버리는 걱정이 조금 줄어듭니다.
끝에
이번은 여기까지입니다.
테스트 환경을 구축하는 데 어려움을 겪고 있는 사람의 도움이 되길 바랍니다.
기재에 실수가 있거나 쓰는 방법이 다른 등 있으면 코멘트 잘 부탁드립니다!
Reference
이 문제에 관하여(Apache2.4에서 테스트 환경을 구축하는 이야기), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/harutya/items/cfe412c748337396e4a7텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)