Keycloak使用nginx配置https
nginx server中需包含如下配置
map $http_host $this_host {
"" $host;
default $http_host;
}
map $http_upgrade $proxy_connection {
default upgrade;
"" close;
}
proxy_set_header Upgrade $http_upgrade;
map $http_x_forwarded_proto $the_scheme {
default $http_x_forwarded_proto;
"" $scheme;
}
proxy_set_header X-Real-Scheme $the_scheme;
proxy_set_header X-Forwarded-Proto $the_scheme;
map $http_x_forwarded_host $the_host {
default $http_x_forwarded_host;
"" $this_host;
}
proxy_set_header X-Forwarded-Host $the_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $the_scheme;
修改standalone.xml
在http-listener中添加proxy-address-forwarding
在http-listener中添加redirect-socket
<subsystem xmlns="urn:jboss:domain:undertow:10.0" default-server="default-server" default-virtual-host="default-host" default-servlet-container="default" default-security-domain="other" statistics-enabled="${wildfly.undertow.statistics-enabled:${wildfly.statistics-enabled:false}}">
<buffer-cache name="default"/>
<server name="default-server">
<http-listener name="default" socket-binding="http" proxy-address-forwarding="true" redirect-socket="proxy-https"/>
<https-listener name="https" socket-binding="https" security-realm="ApplicationRealm" enable-http2="true"/>
...
</server>
</subsystem>