这是我的网站conf(使用nginx v1.25.1):
# Redirect to https
server {
listen 80;
server_name domain.name www.domain.name;
location ^~ /.well-known/acme-challenge/ {
root /acme-challenge; # Make sure this path is correct
allow all;
}
location / {
return 301 https://www.domain.name/$request_uri;
}
}
# Redirect from HTTPS non-www to HTTPS www
server {
listen 443 ssl;
listen [::]:443 ssl;
http2 on;
server_name domain.name;
# SSL configuration
ssl_certificate /ssl/live/domain.name/fullchain.pem;
ssl_certificate_key /ssl/live/domain.name/privkey.pem;
location ^~ /.well-known/acme-challenge/ {
root /acme-challenge; # Make sure this path is correct
allow all;
}
location / {
return 301 https://www.domain.name/$request_uri;
}
}
# Redirect to the specific path
server {
listen 443 ssl;
listen [::]:443 ssl;
http2 on;
server_name www.domain.name;
# SSL configuration
ssl_certificate /ssl/live/domain.name/fullchain.pem;
ssl_certificate_key /ssl/live/domain.name/privkey.pem;
location ^~ /.well-known/acme-challenge/ {
root /acme-challenge; # Make sure this path is correct
allow all;
}
location / {
return 301 https://www.other.domain.name/app/;
}
}
我曾经使用
listen 443 ssl hhtp2;
但我收到了这些警告:
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead in /etc/nginx/sites-enabled/domain.name:14
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead in /etc/nginx/sites-enabled/domain.name:30
然后我搜索发现了这个:https://www.nginx.com/blog/nginx-plus-r30-released/
这告诉我们:
更改此:
listen 443 ssl http2;
对此:
listen 443 ssl; http2 on;
但现在我收到这个警告:
nginx: [warn] protocol options redefined for 0.0.0.0:443 in /etc/nginx/sites-enabled/domain.name:20
我认为这没什么大不了的,但我想删除所有警告,但我在 Google 或 ChatGPT 上没有发现任何内容。
这里有什么消息吗? 我也有同样的问题。