LoginSignup
9
10

More than 5 years have passed since last update.

Apache/mod_ssl https設定メモ

Last updated at Posted at 2015-09-27

概要

  • Apacheとmod_sslをつかって、httpsを使えるようにする

環境

  • OS:CentSO /Redhat 6.x
  • httpd/mod_ssl:2.2.x

手順

Apacheとmod_sslをインストール


# yum install -y httpd mod_ssl
# chkconfig httpd on

ブラウザアクセスし、Apacheの画面が表示されることを確認

http://hogehoge.com
キャプチャ3.JPG

秘密鍵 (Private Key)、サーバ証明書(CRT)を配置する

  • 秘密鍵 (Private Key):server.key
  • サーバ証明書(CRT):server.crt

# ls /etc/httpd/conf/ssl.key/
server.key
# ls /etc/httpd/conf/ssl.crt/
server.crt

ssl.confを編集する

  • 秘密鍵、サーバ証明書のファイル名、配置場所を修正する
/etc/httpd/conf.d/ssl.conf
# SSLCertificateFileを実際の配置場所にあわせる
SSLCertificateFile /etc/httpd/conf/ssl.crt/server.crt

# SSLCertificateKeyFileを実際の配置場所にあわせる
SSLCertificateKeyFile /etc/httpd/conf/ssl.key/server.key

rewrite.confを編集する

  • httpリクエストが来た際、httpsリクエストへリダイレクトさせる
/etc/httpd/conf.d/rewrite.conf
<ifModule mod_rewrite.c>
      RewriteEngine On
      RewriteCond %{HTTPS} off
      RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
</ifModule>

Apache再起動


# service httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]

ブラウザアクセスし、https通信でApacheの画面が表示されることを確認

無題4.jpg

9
10
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
9
10