1
夥計!如何編寫用於替換查詢字符串中的查詢參數的nginx重寫規則
,我們有以下的http請求:
我們想從 「some.domain.com」 取代redirect_uri
爲 「other.domain.com」。
怎麼辦?
感謝
夥計!如何編寫用於替換查詢字符串中的查詢參數的nginx重寫規則
,我們有以下的http請求:
我們想從 「some.domain.com」 取代redirect_uri
爲 「other.domain.com」。
怎麼辦?
感謝
你需要做的是這樣的
location /auth/realms/master-realm/protocol/openid-connect/auth {
if ($args ~* "(.*)(some\.domain\.com)(.*)") {
set $args "$1other.domain.com$3";
return 301 $scheme://$host$uri$args;
}
}
測試:
curl -I "vm/auth/realms/master-realm/protocol/openid-connect/auth?response_type=code&client_id=regportal&redirect_uri=http%3A%2F%2Fsome.domain.com%2Fregportal%2Fsso%2Flogin&state=a49a02d5-f873-453f-9148-61793f11ecf3&login=true&scope=openid"
HTTP/1.1 301 Moved Permanently
Server: openresty/1.11.2.2
Date: Fri, 15 Sep 2017 06:01:51 GMT
Content-Type: text/html
Content-Length: 191
Connection: keep-alive
Location: http://vm/auth/realms/master-realm/protocol/openid-connect/authresponse_type=code&client_id=regportal&redirect_uri=http%3A%2F%2Fother.domain.com%2Fregportal%2Fsso%2Flogin&state=a49a02d5-f873-453f-9148-61793f11ecf3&login=true&scope=openid
正常工作。謝謝! – ricoshet