반응형
웹서버에서 http를 https(SSL)로 리다이렉트하는 방법
rewrite 모듈 활성화
LoadModule rewrite_module modules/mod_rewrite.so
###httpd.conf
$ vim httpd.conf
LoadModule rewrite_module modules/mod_rewrite.so
모듈 확인
httpd -M
$ httpd -M | egrep -i rewrite
rewrite_module (shared)
가상호스트 설정
httpd-vhosts.conf 편집
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
$ vim httpd-vhosts.conf
...
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "/var/www/wwwroot"
ServerName test.sangchul.kr
ServerAlias t.sangchul.kr
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
CustomLog "|/usr/sbin/cronolog /logs/access/test.sangchul.kr-access-%Y%m%d.log" scombined
ErrorLog "|/usr/sbin/cronolog /logs/error/test.sangchul.kr-error-%Y%m%d.log"
<Directory "/var/www/wwwroot">
Options FollowSymLinks
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
아파치 configure 문법 검사 및 재기동
###run syntax check for config files
$ apachectl -t
Syntax OK
$ systemctl restart httpd
Enter TLS private key passphrase for test.sangchul.kr:443 (RSA) : **********
$ ps -ef | grep -v grep | egrep httpd
root 2575008 1 0 12:09 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 2575038 2575008 0 12:09 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 2575039 2575008 0 12:09 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 2575040 2575008 0 12:09 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 2575041 2575008 0 12:09 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 2575253 2575008 0 12:09 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
728x90
반응형
'리눅스' 카테고리의 다른 글
[명령어] which, whereis, locate 명령어 (0) | 2020.12.18 |
---|---|
[리눅스] CentOS7에서 시스템 메시지 로그 필터링 (0) | 2020.12.18 |
CentOS End of Lifetime (EOL) Dates (0) | 2020.12.16 |
HP 서버 스토리지 정보 확인(raid) (0) | 2020.12.16 |
[Apache] 아파치 액세스 로그 설정 (0) | 2020.12.15 |