セットアップは次のようになります。たとえば、ドメインがあり、example.com
Apache2 をセットアップしましたVirtualDocumentRoot。この方法では、サブドメインを特定のフォルダーに簡単にポイントできます。
ファイルsites-available/websites.conf:
ServerName example.com
ServerAlias *.example.com
VirtualDocumentRoot /var/www/websites/%1/
<Directory /var/www/websites/%1/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
そのため、アクセスすると、 Web サイトのディレクトリの下のフォルダーtest.example.comが検索されtest、提供されます。
これは意図したとおりに動作しますが、SSL には Let's Encrypt を使用したいと考えていました。これはまだワイルドカード証明書を処理できません。このような問題にはどのように対処すればよいでしょうか?
現在の状況:
Let's Encrypt 証明書をインストールしました:sudo certbot --apache -d example.com -d admin.example.com -d www.example.com
ファイル:sites-available/000-default.conf:
DocumentRoot /var/www/websites/current/
<Directory /var/www/websites/current/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<IfModule mod_dir.c>
DirectoryIndex index.php index.pl index.cgi index.html index.xhtml index.htm
</IfModule>
# Let's Encrypt Redirect
RewriteEngine on
RewriteCond %{SERVER_NAME} =example.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
すべてのサブドメインは引き続き にリダイレクトされますhttps。トップドメイン のみexample.com、https にする必要があります。admin.example.comwww.example.com
答え1
問題は、サイト固有の方法で構成のスコープを設定していないことです。
「サイトごとに」個別の設定ファイルは、実際には Apache httpd の機能ではないことに注意することが重要です。これは、管理上の利便性のための (比較的一般的な) 慣例にすぎず、最終的にはIncludeメインの設定ファイル内のディレクティブを使用して、設定が読み込まれるときにすべてを 1 つの設定にマージします。
通常、これらの個別の構成ファイルには、その効果を範囲指定するためのすべての内容が含まれていますVirtualHostが、http から https へのリダイレクトを含むグローバル構成のみが含まれているようです。
答え2
サーバーから証明書を作成しようとしています
certbot certonly -d *.example.com -d admin.example.com -d www.example.com
Wildcard domains are not supported: *.example.com


