我有一个主服务器模块:
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;
}
}以及驾驶舱反向代理的服务器模块:
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;然后,在system.mydomain.com上登录Cockpit会返回一个只显示protocol-error的页面,而连接到system.mydomain.com则会返回一个状态代码500。
有没有办法将nginx配置为使用HTTP1.1和HTTP2上的所有其他流量来处理驾驶舱请求?
发布于 2021-01-10 04:16:57
不幸的是,您不能在同一端口(443)上运行HTTP1.1和h2。如果您能够选择不同的端口,那么您当然可以解决这个问题。
如果您将一个服务器块设置为http2,则具有相同端口的所有其他块也会隐式地在h2上运行。
当然,我在这里只是指Nginx。我不知道Apache或HAProxy是怎么回事。
https://stackoverflow.com/questions/65647164
复制相似问题