LoginSignup
0
0

More than 3 years have passed since last update.

Apache 2.4.37でバーチャルホストがSSLで繋がらなかった話

Last updated at Posted at 2021-02-02

何も役に立たない自己紹介

初めまして、ウェブ開発頑張りたいけどどうせやらない系デベロッパー(笑)のReisan03です。

何があったのよあーた

バーチャルホストを設定しても何故か繋がりませんでした。解決したので備忘録を。

結局何が原因だったのよあーた

443ポートのVirtualHostを設定してなかったのが原因でした。
<VirtualHost *:443>って入れたらちゃんと動きました。

何を使ってるのよあーた


Apache

2.4.37 CentOS

CentOS 8 Streamかなにか使ってます....(もう思い出したくない)

詳しく聞かせなさいよあーた

DocumentRootは/var/www/html
何故か繋がらなかったhoge.marumaru.dev/var/www/html/hoge/に配置していると仮定します。

もともと、/etc/httpd/conf.d/hoge.confには以下の内容が書いてありました。

<VirtualHost *:80>
DocumentRoot "/var/www/html/hoge"
ServerName hoge.marumaru.dev

<Directory "/var/www/html/hoge">
Require all granted
AllowOverride all
Options SymLinksIfOwnerMatch FollowSymLinks MultiViews
</Directory>
</VirtualHost>

よく考えたら一発で何が原因かはわかりますよね。
<VirtualHost *:443>が居ないんですよね...
これだとhttpsに強制移動する私のhoge.marumaru.devにはアクセスできません...(悲しい)

ということで以下の内容を追加してみました。

<VirtualHost *:443>
DocumentRoot "/var/www/html/hoge"
ServerName hoge.marumaru.dev
<Directory "/var/www/html/hoge">
Require all granted
AllowOverride all
Options SymLinksIfOwnerMatch FollowSymLinks MultiViews
</Directory>
SSLEngine On
SSLProtocol all -SSLv2

SSLCertificateFile [Key Location]
SSLCertificateKeyFile [Key Location]
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>

追記して保存して
systemctl restart httpd.service
で完成です。やったね。終わり。

0
0
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
0
0