我已让 nextcloud 在 VirtualHost 中运行(请参阅下面的配置)。当我在 Ubuntu 16.04 上的 Apache 中仅启用虚拟主机(nextcloud.conf)时,它就可以运行。但是当我启用 000-default.conf 和 default-ssl.conf 时,它总是将我带到主页而不是 nextcloud 页面。我已发布所有配置文件。我想让默认虚拟主机运行,因为我想捕获所有与 nextcloud 配置不匹配的 URL。
nextcloud.conf
<VirtualHost *:80>
ServerName storage.declanmarks.pw
RewriteEngine On
RewriteCond %{HTTP_HOST} ^storage.declanmarks.pw
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
#RewriteRule ^(.*)$ https://storage.declanmarks.pw$1 [R,L]
</VirtualHost>
<VirtualHost *:443>
Alias /files /var/www/files
ServerName storage.declanmarks.pw
DocumentRoot /var/www/nextcloud/
ServerAlias storage.declanmarks.pw
<Directory /var/www/nextcloud/>
Options +FollowSymlinks
AllowOverride All
<IfModule mod_dav.c>
Dav off
</IfModule>
SetEnv HOME /var/www/nextcloud
SetEnv HTTP_HOME /var/www/nextcloud
</Directory>
# SSL
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/storage.declanmarks.pw/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/storage.declanmarks.pw/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/storage.declanmarks.pw/fullchain.pem
Header always set Strict-Transport-Security "max-age=63072000; includeSubdomains;"
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
默认 SSL 配置文件
<VirtualHost *:443>
DocumentRoot /var/www/main
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# SSL
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/storage.declanmarks.pw/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/storage.declanmarks.pw/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/storage.declanmarks.pw/fullchain.pem
</VirtualHost>
000-默认.conf
<VirtualHost *:80>
DocumentRoot /var/www/main
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>