我正在尝试在 keycloak 服务器中进行身份验证,但是 redirect_uri 没有附带上下文 (/admin/)。
Nginx 生成了错误的 URI redirect_uri:hxxps://***.pt/auth/realms/example/protocol/openid-connect/auth?response_type=code&client_id=appmovel&redirect_uri=http%3A%2F%2F新服务%2F&state=... 由于 URL 上没有 /admin/ 导致回调失败。
nginx 配置文件:
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
return 301 https://$host$request_uri;
}
# HTTPS server
server {
listen 443 ssl;
server_name localhost;
ssl_certificate cert.pem;
ssl_certificate_key cert.key;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location /api {
absolute_redirect off;
proxy_pass http://web-service:8080/api;
}
location /admin/ {
proxy_set_header Host $host;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://web-service:8080/;
}
}
我应该如何以及在何处配置以在redirect_uri中保留/添加上下文(/admin)?可以通过nginx重写规则完成吗?