250x250
반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- launch.json
- 구글 클라우드
- html
- Linux
- Xdebug
- Fail2ban
- mysql
- vscode
- SSL
- non-www
- https
- crontab
- php
- MariaDB
- LetsEncrypt
- root
- centos
- wordpress
- new user
- front page
- git pull
- CentOS7
- Google Cloud
- Liniux
- Mac
- home page
- Certbot
- DOM Parser
- child theme
- Apache
Archives
- Today
- Total
between 0 and 1
[SSL, Apache] http -> https & www to non-www setting 본문
Software Development Engineering/Dev.Info.
[SSL, Apache] http -> https & www to non-www setting
devxpert.yoon 2021. 2. 10. 00:37728x90
반응형
Step 1. create ssl certificate
$ letsencrypt
Step 2. create .htaccess file on webroot and save below contents.
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{ENV:HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,R=301,NE]
Step 3. set vhost.conf
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com/www
ErrorLog /var/www/example.com/log/error.log
CustomLog /var/www/example.com/log/requests.log combined
#AllowOverride All
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.example.com [OR]
RewriteCond %{SERVER_NAME} =example.com
RewriteRule ^ https://issuemore.com%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
Rewrite engine will redirect all http access to https
Step 4. set vhost-le-ssl.conf
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com/
ErrorLog /var/www/example.com/log/error.log
CustomLog /var/www/example.com/log/requests.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.example.com
RewriteRule ^ https://example.com%{REQUEST_URI} [END,NE,R=permanent]
SSLCertificateFile /etc/letsencrypt/live/example.com/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateChainFile /etc/letsencrypt/live/example.com/chain.pem
</VirtualHost>
</IfModule>
Step 5. restart httpd
$ sudo systemctl restart httpd
728x90
반응형
'Software Development Engineering > Dev.Info.' 카테고리의 다른 글
[SSL] Auto-renewal SSL on CentOS (let's encrypt, certbot) (0) | 2021.02.09 |
---|---|
[SSL] Let's encrypt on Cent OS (how to install) (0) | 2021.02.09 |
[Git] Adding an existing project to GitHub (기존 프로젝트 깃허브에 올리기) (0) | 2021.01.26 |
[VSCode] git pull - There is no tracking information for the current branch (0) | 2021.01.24 |
[Server] SSL for Localhost (Local Development Environment) (0) | 2021.01.03 |