こなさんち

しがないフリーランスエンジニアの備忘録。

conohaでSSL化(続くよ)

やること

1.http通信とhttps通信をF/W許可 2.必要なアプリケーションのインストール

1.http通信とhttps通信をF/W許可

sudo firewall-cmd --list-all

を実行します。

結果、

public (active)
  target: default
  icmp-block-inversion: no
  interfaces: eth0 eth1
  sources: 
  services: ssh dhcpv6-client 
  ports: 
  protocols: 
  masquerade: no
  forward-ports: 
  source-ports: 
  icmp-blocks: 
  rich rules: 

となる。

services: ssh dhcpv6-client 

が許可されてるプロトコルなので、httpとhttpsがほしいんですね。 ※私の場合既にhttpはありました。 そこで、次のコマンド。

firewall-cmd --permanent --add-service=http --zone=public
firewall-cmd --permanent --add-service=https --zone=public
firewall-cmd --reload

1行目でhttpの許可、2行目でhttpsの許可。 最後にリロードしましょってだけです。

このコマンド、"success"って一言しか言ってくれないのはシンプルで良き。 再度確認しましょ↓

sudo firewall-cmd --list-all

を実行します。

結果、

public (active)
  target: default
  icmp-block-inversion: no
  interfaces: eth0 eth1
  sources: 
  services: ssh dhcpv6-client http https
  ports: 
  protocols: 
  masquerade: no
  forward-ports: 
  source-ports: 
  icmp-blocks: 
  rich rules: 

OKOK。

2.必要なアプリケーションの実行

流すだけっすね。

yum install epel-release
yum install certbot python-certbot-apache

そしたら

certbot certonly --webroot -w /var/www/html -d www.example.com

で発行してあげましょう。(ドメインは自分で変えてね。)

メールアドレスを聞かれるから、入力して、あとは AgreeとYesを入力すればよき。

メールは一応届きますぞ。

Apacheに証明書を設定

最後、発行された証明書を設定しましょうかね。

vim /etc/httpd/conf.d/ssl.conf

SSLCertificateFile /etc/letsencrypt/live/www.example.com/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/www.example.com/privkey.pem

systemctl restart httpd

はえー、こんなもんか。ホクホク。