HAProxy change header - haproxy

I want to configure my HAProxy (V1.7) to change the Location-field in the header of the server-response before sending it back to the client. I tried various options but wasn't able to get the right result. Any ideas?

Related

Haproxy removing headers when using http-request return code

I am trying to add OPTIONS inside haproxy instead adding it in every rest api. I am using something like this:
acl is_options method OPTIONS
use_backend cors_backend if is_options
backend cors_backend
http-request return status 200
In previous part of haproxy.cfg I added some CORS headers and everything works fine for api calls going to my rest api servers, but when I use cors_backend to send response directly from haproxy, all headers I added above are removed.
Is this expected, is there some way to preserve headers? Maybe it is not good idea to add OPTIONS to haproxy at all

fiddler modify response header

I'm working with an API that doesn't yet have CORS setup. So, instead of waiting until that's setup, I thought I could use fiddler to add the Access-Control-Allow-Origin header to the responses coming from the server. I haven't used fiddler for a while and can't figure out how to add headers to the response. Is this not supported in the free version of fiddler-everywhere?
It's not ideal, but I found a workaround. After the requests have gone off once, I right-click the ones I'm interested in and select "Add new rule". The rule will automatically do an exact match to the URL and sets the action of "Return manually crafted response" If I edit the rule, the header can be added in the raw text.

Fiddler Dynatrace integration

I added request header in fiddler by using the syntax below:
oSession.oRequest["NewHeaderName"] = "New header value";
Ex: oSession.oRequest["Test"] = "DT";
I could see the header in fiddler, but unable to see the same in "Tagged web request"
Any help is greatly appreciated.
In order to work this code should be in the OnBeforeRequest method. Is it there?
Also if there are other proxies between Fiddler and Dynatrace they ight remove the header. The chance for that happening increases if this is some standard HTTP header. Have in mind that if your system had a proxy set before running Fiddler then Fiddler will automatically use the original system proxy as an upstream proxy.

Disable REST URI calls

I am developing a project which can disable a particular REST URI at runtime so that consumers will get an error. I have created interface/controller for disabling a URI. But I can not figure out how to disable it.
I thought of setting disable flag for the URI and sending blank data, but consumer needs to see an error.
I can not use Response every where.
Need Help
Implement a ContainerRequestFilter(more on filters), which when a specific criteria is met will call:
ContainerRequestContext.abortWith(javax.ws.rs.core.Response)
with a proper HTTP status code.

Send Headername and Headerkey Trougth Browser

I have added security to one of my services, and I would like to test it,
Is there some way of adding the Key and Name in the Header?
How can I do that in Fiddler, What do I have to type?
If you simply want to add a custom header to all outbound requests, go to the FILTERS tab and in the Request Headers section, add your custom header.