![Nginx 四级域名通配符重定向](https://linux22.com/image/763784/Nginx%20%E5%9B%9B%E7%BA%A7%E5%9F%9F%E5%90%8D%E9%80%9A%E9%85%8D%E7%AC%A6%E9%87%8D%E5%AE%9A%E5%90%91.png)
我目前正在https
我的域名的二级和三级上提供服务(通配符),并将所有http
流量重定向到https
这些。现在我想为 4 级子域名提供服务http
仅有的,因为我无法以以下形式获取任何域的证书*.*.example.com
# Now
example.com -> https:
*.example.com -> https:
# What I want
*.*.example.com -> http:
我尝试了以下配置,但它仍然重定向到 https。.example.com:
server {
listen 80;
listen [::]:80;
server_name example.com *.example.com;
include /etc/nginx/headers.conf;
location / {
return 301 https://$host$request_uri;
}
access_log off;
}
server {
listen 80;
listen [::]:80;
server_name *.*.example.com;
include /etc/nginx/headers.conf;
location / {
proxy_pass http://127.0.0.1:8087/;
proxy_set_header Host $host;
}
access_log off;
}
server {
server_name example.com *.example.com;
listen 443 ssl http2;
listen [::]:443 ssl http2;
ssl_certificate /cert.pem;
ssl_certificate_key /key.pem;
include /etc/nginx/headers.conf;
location / {
proxy_pass http://127.0.0.1:8087/;
proxy_set_header Host $host;
}
access_log off;
}
编辑:优先级不相关。PCRE 正在运行。