Search code examples
azurehttp-redirectazure-application-gateway

rewrite url redirect with Azure Application Gateway


I would like to use the application gateway as a reverse proxy.

All authentication request from the frontend should be routed to /auth. The application gateway should then replace query parameters of the request and should URL redirect to the resulting page. I couldn't get that working on Azure.


Example:

Application gateway is reachable under test.com

Request to: test.com/auth

Application gateway modifies request to test.b2clogin.com/?scope=XY&client_id=235

Application gateway url redirects request to test.b2clogin.com/?scope=XY&client_id=235


Is this possible? I couldn't figure out how to configure that

Thank you very much


Solution

  • after hours of searching I finally figured out how to do it:

    1. created a /auth endpoint. This one is routing to the test.b2clogin.com backend. (actually that backend is never hit via that rule)
    2. created a rewrite rule for /auth: that rule modifies url and query, set URL to /authredirect and on query I set/modify the query parameters that I require. Enable "Re-evaluate path map" on this one, so that it directly redirects to /authredirect.
    3. configure the /authredirect endpoint as URL Redirect to test.b2clogin.com/.../authorize. Also enable "Include query string"

    This way Im able to modify the incoming request under /auth and after modification I redirect it to /authredirect.

    Hope that it helps someone :)