我的站點中有以下配置可用(帶有要啟用的符號鏈接):
#subdomain site
server {
listen 443 ssl http2;
server_name dokuwiki.[censored].org;
root /var/www/html/dokuwiki;
index index.php index.html;
include /etc/nginx/templates/ssl.tmpl;
location / {
try_files $uri $uri/ @dokuwiki;
}
location @dokuwiki {
rewrite ^/_media/(.*) /lib/exe/fetch.php?media=$1 last;
rewrite ^/_detail/(.*) /lib/exe/detail.php?media=$1 last;
rewrite ^/_export/([^/] )/(.*) /doku.php?do=export_$1&id=$2 last;
rewrite ^/(.*) /doku.php?id=$1&$args last;
}
location ~ \.php$ {
# Caution: be sure the php7.2-fpm.sock matches your version
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /(data|conf|bin|inc|vendor)/ {
deny all;
}
}
我想在站點根目錄中有一個不同的站點:
#root site
server {
listen 80;
server_name [censored].org;
root /var/www/html/site;
index index.html;
}
根站點現在只是一個虛擬的。當我嘗試加載它時,瀏覽器嘗試加載子域站點,但由于 ssl 證書(為子域設定)不匹配而發出警告。
顯然我做錯了什么,但什么?
uj5u.com熱心網友回復:
嘗試在沒有 SSL 的情況下縮減到最低配置,并確保首先適用于 2 個域:
server {
listen 80;
server_name example.com;
return 200 "example.com";
}
server {
listen 80;
server_name 1.example.com;
return 200 "1.example.com";
}
$ curl http://example.com/
example.com
$ curl http://1.example.com/
1.example.com
然后,將 SSL 添加到 HTTPS 端點以確保正常作業:
server {
listen 443 ssl http2;
ssl_certificate example.com.crt;
ssl_certificate_key example.com.key;
server_name example.com;
return 200 "example.com";
}
$ curl https://example.com/
example.com
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/388353.html
