我创建了一个网站(Nginx)并且一切正常,除了当我尝试浏览子域时,似乎即使是子域前缀也像“www”一样受到威胁,因为它总是指向主域,除非我添加端口号.
例如:example.com => 带我到主页。都好
sub.example.com => 带我到主页。不好
sub.example.com:3000 => 带我去子域...很好但不实用,我想在没有“:3000”的情况下达到相同的结果
server {
listen 80;
listen [::]:80;
server_name *.example.com;
return 301 https://$host$request_uri;
location / {
proxy_pass http://localhost:3000/;
}
}
server{
listen 443 ssl;
server_name *.sexample.com example.com;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
location / {
proxy_pass http://localhost:3000/;
try_files $uri $uri/ =404;
}
}
我忘了提到我正在使用通配符子域来处理子域请求