설정은 이렇습니다. 예를 들어 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>
따라서 방문하면 웹사이트 디렉토리 아래의 폴더를 test.example.com검색하여 test제공합니다.
이는 의도한 대로 작동하지만 SSL에 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. topdomain 만이 example.com며 https admin.example.com여야 www.example.com합니다.
답변1
문제는 사이트별 방식으로 구성의 범위를 지정하지 않았다는 것입니다.
"사이트별" 별도의 구성 파일은 실제로 Apache httpd 기능이 아니라는 점에 유의하는 것이 중요합니다. 이는 구성이 로드될 때 결국 Include기본 구성 파일의 지시문을 사용하여 모든 것을 단일 구성으로 병합하는 관리 편의를 위한 (상대적으로 일반적인) 규칙일 뿐입니다.
일반적으로 이러한 개별 구성 파일에는 효과 범위를 지정하기 위한 모든 내용이 포함되어 있지만 VirtualHosthttp에서 https로의 리디렉션을 포함하여 전역 구성만 있는 것 같습니다.
답변2
서버에서 인증서를 생성하려고 합니다.
certbot certonly -d *.example.com -d admin.example.com -d www.example.com
Wildcard domains are not supported: *.example.com


