Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set up an HTTP proxy to insert a header

I need to test some HTTP interaction with a client I'd rather not modify. What I need to test is the behavior of the server when the client's requests include a certain, static header.

I'm thinking the easiest way to run this test is to set up an HTTP proxy that inserts the header on every request. What would be the simplest way to set this up?

like image 371
Logan Avatar asked Sep 30 '08 18:09

Logan


People also ask

How do I add a header to my HTTP request?

To add custom headers to an HTTP request object, use the AddHeader() method. You can use this method multiple times to add multiple headers. For example: oRequest = RequestBuilder:Build('GET', oURI) :AddHeader('MyCustomHeaderName','MyCustomHeaderValue') :AddHeader('MySecondHeader','MySecondHeaderValue') :Request.

How do I add a header to an HTTP response?

Select the web site where you want to add the custom HTTP response header. In the web site pane, double-click HTTP Response Headers in the IIS section. In the actions pane, select Add. In the Name box, type the custom HTTP header name.

Is proxy a standard HTTP header?

It is a request type header and is an alternative and de-facto standard version of the Forwarded header which is used when a client connects to a web server through an HTTP proxy or load balancer for identifying the original IP address. It is a request-type header.

What is proxy authorization header?

The HTTP Proxy-Authorization request header contains the credentials to authenticate a user agent to a proxy server, usually after the server has responded with a 407 Proxy Authentication Required status and the Proxy-Authenticate header.


1 Answers

I do something like this in my development environment by configuring Apache on port 80 as a proxy for my application server on port 8080, with the following Apache config:

NameVirtualHost * <VirtualHost *>    <Proxy http://127.0.0.1:8080/*>       Allow from all    </Proxy>    <LocationMatch "/myapp">       ProxyPass http://127.0.0.1:8080/myapp       ProxyPassReverse http://127.0.0.1:8080/myapp       Header add myheader "myvalue"       RequestHeader set myheader "myvalue"       </LocationMatch> </VirtualHost> 

See LocationMatch and RequestHeader documentation.

This adds the header myheader: myvalue to requests going to the application server.

like image 191
Peter Hilton Avatar answered Sep 19 '22 00:09

Peter Hilton