Vikram Ranabhatt
Vikram Ranabhatt

Reputation: 7630

changing Location in the http response

While accessing https://myexample.com/adminui/ server send 303 and I am getting response in the browser as below

http://uaa.devtest3.io/oauth/authorize?response_type=code&client_id=admin_ui_client&redirect_uri=https://admin.devtest3.io/login

I want it to change it

http://myexample.com/oauth/authorize?response_type=code&client_id=admin_ui_client&redirect_uri=https://myexample.com/adminui/login

I tried following entry in haproxy.config file,but this is not working.

resirep ^Location:\ http://uaa.devtest3.io/oauth/authorize?response_type=code&client_id=admin_ui_client&redirect_uri=https://admin.devtest3.io/login   Location:\ http://myexample.com/uaa/oauth/authorize?response_type=code&client_id=admin_ui_client&redirect_uri=https://myexample.com/adminui/login

UPDATED I need further help to change

https://uaa.devtest3.io/login;jsessionid=4A0ADA8DDB7CD09C2B50F4A41945BBDB to https://myexample.com/uaa/login;jsessionid=4A0ADA8DDB7CD09C2B50F4A41945BBDB

I tried this

rspirep ^Location:\ (https?://uaa.devtest3.io;jsessionid=([0-9A-Z](.*) )Location:\ myexample.com \3 if hdr_location

This is not working.I feel regex i am using is wrong.I am not verse in this regexe. Please guide me on this

Upvotes: 0

Views: 1302

Answers (1)

JamesStewy
JamesStewy

Reputation: 1078

First, the resirep command does not appear to exist as far as I can tell. I think the command you need is rspirep. Second, if you are using HAProxy version 1.5 or below you need to escape /, & and ? as well as the spaces.

Resulting configuration:

rspirep ^Location:\ http:\/\/uaa.devtest3.io\/oauth\/authorize\?response_type=code\&client_id=admin_ui_client\&redirect_uri=https:\/\/admin.devtest3.io\/login   Location:\ http:\/\/myexample.com\/uaa\/oauth\/authorize\?response_type=code\&client_id=admin_ui_client\&redirect_uri=https:\/\/myexample.com\/adminui\/login

Hope that helps.

Update *Fixed

rspirep ^Location:\ https:\/\/uaa.devtest3.io\/login;jsessionid=([0-9A-Z]*)   Location:\ https:\/\/myexample.com\/uaa\/login;jsessionid=\1

([0-9A-Z]*) - matches and captures a string of any length that contains capital letters and numbers.

\1 - place the first captured string here

*tested in HAProxy 1.5.15.

Upvotes: 1

Related Questions