
我在我的伺服器上啟動並運行了兩個網站(nextcloud.example.com
(Nextcloud 實例)和example.com
(Grav 實例))。我在伺服器上新增了 Postfix 配置,現在我也可以發送郵件了。但我把我的證書弄亂了,所以我重新做了......
這主要問題現在是這樣,當我嘗試打開它時,example.com
它總是呼叫example.com/index.php/login
它呈現登入頁面,nextcloud.example.com
但我期待我的 Grav 主頁。當我打電話時example.com/admin
它也解析為example.com/index.php/login
.
我對這個主題還很陌生,所以我希望這會是相關數據:
$ apachectl configtest
Syntax OK
我確實在這裡插入了我的conf文件,但是StackExchange將我的文字區域標記為垃圾郵件。所以我刪除了它們。我很高興為您提供更多信息,只是我不被允許......
編輯:
apache2ctl -S
VirtualHost configuration:
127.0.1.1:443 example.com (/etc/apache2/sites-enabled/example.com-le-ssl.conf:2)
127.0.1.1:80 example.com (/etc/apache2/sites-enabled/example.com.conf:1)
5.252.225.176:443 nextcloud.example.com (/etc/apache2/sites-enabled/nextcloud.example.com-le-ssl.conf:2)
5.252.225.176:80 nextcloud.example.com (/etc/apache2/sites-enabled/nextcloud.example.com.conf:1)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex rewrite-map: using_defaults
Mutex ssl-stapling-refresh: using_defaults
Mutex ssl-stapling: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="/var/run/apache2/" mechanism=default
Mutex mpm-accept: using_defaults
Mutex watchdog-callback: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33 not_used
Group: name="www-data" id=33 not_used
<VirtualHost nextcloud.example.com:443>
DocumentRoot /var/www/nextcloud.example.com/htdocs/
ServerName nextcloud.example.com
<Directory /var/www/nextcloud.example.com/htdocs/>
Require all granted
AllowOverride All
Options FollowSymLinks MultiViews
<IfModule mod_dav.c>
Dav off
</IfModule>
</Directory>
RewriteEngine off
# Some rewrite rules in this file were disabled on your HTTPS site,
# because they have the potential to create redirection loops.
#RewriteCond %{SERVER_NAME} =nextcloud.example.com
#RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>
<IfModule mod_ssl.c>
<VirtualHost example.com:443>
DocumentRoot /var/www/example.com/htdocs/
ServerName example.com
<Directory /var/www/example.com/htdocs/>
Require all granted
AllowOverride All
Options FollowSymLinks MultiViews
<IfModule mod_dav.c>
Dav off
</IfModule>
</Directory>
RewriteEngine on
# Some rewrite rules in this file were disabled on your HTTPS site,
# because they have the potential to create redirection loops.
#RewriteCond %{SERVER_NAME} =example.com
#RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>
答案1
您可能需要將 VirtualHost 指令中的主機名稱變更為*
.也就是說,而不是
<VirtualHost nextcloud.example.com:443>
ServerName nextcloud.example.com
...
</VirtualHost>
<Virtualhost example.com:443>
ServerName example.com
...
</VirtualHost>
嘗試
<VirtualHost *:443>
ServerName nextcloud.example.com
...
</VirtualHost>
<Virtualhost *:443>
ServerName example.com
...
</VirtualHost>
一般來說,VirtualHost 的參數應該是一個 IP 位址,或是*
符合所有 IP 位址。
如果 Apache 接收連線的 IP 位址與 example.com 的 DNS 位址不同,例如,如果 example.com 在代理程式後面,則上面的第一種形式將會失敗。在這種情況下,Apache 將回退到從預設虛擬主機提供服務,這是第一個虛擬主機,在您的情況下,它似乎是 nextcloud.example.com。