我有一个主服务器块:
conf.d/mydomain.conf
server {
listen 80;
listen [::]:80;
server_name mydomain.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name mydomain.com;
root /var/www/mydomain.com;
index index.html index.php;
include modules/ssl.conf;
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
location / {
try_files $uri $uri/ =404; autoindex on;
}
}
以及 Cockpit 反向代理的服务器块:
conf.d/system.mydomain.com.conf
server {
listen 80;
listen 443 ssl;
server_name system.mydomain.com;
location / {
# Required to proxy the connection to Cockpit
proxy_pass https://127.0.0.1:9090;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
# Required for web sockets to function
proxy_http_version 1.1;
proxy_buffering off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
# Pass ETag header from Cockpit to clients.
# See: https://github.com/cockpit-project/cockpit/issues/5239
gzip off;
}
}
我还有一条从 system.mydomain.com 到 mydomain.com 的 CNAME 记录。
这很好用,除非我想让主服务器块使用 HTTP2:
listen 443 ssl http2;
listen [::]:443 ssl http2;
然后,登录 Cockpit atsystem.mydomain.com
返回一个页面,该页面仅显示,protocol-error
并且连接system.mydomain.com
返回一个 status code 500
。
有什么方法可以配置 nginx 以使用 HTTP 1.1 和 HTTP2 上的所有其他流量来处理 Cockpit 请求?