Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTTP rewriter for docker

Tags:

docker

I want to run a docker container, and somehow intercept/modify HTTP responses in the host. That means, basically take every HTTP response coming out of the container, and modify it before sending it back to the user. Is there a standard way to do this in docker?

like image 509
Sam Lee Avatar asked Dec 04 '14 07:12

Sam Lee


People also ask

Does Docker use HTTP?

The Docker Registry HTTP API is the protocol to facilitate distribution of images to the docker engine. It interacts with instances of the docker registry, which is a service to manage information about docker images and enable their distribution.

What protocol does Docker use to pull images?

local:5000): $ docker image pull myregistry. local:5000/testing/test-image Registry credentials are managed by docker-login(1). Docker uses the https:// protocol to communicate with a registry, unless the registry is allowed to be accessed over an insecure connection.

What is REST API in Docker?

The Docker Engine API is a RESTful API accessed by an HTTP client such as wget or curl , or the HTTP library which is part of most modern programming languages.

What is a Docker manifest?

A manifest list is a list of image layers that is created by specifying one or more (ideally more than one) image names. It can then be used in the same way as an image name in docker pull and docker run commands, for example.


2 Answers

What you could do is create a reverse proxy.

All communication in and out of the docker container is done indirectly, trough the proxy. So clients connect to the reverse proxy, the proxy requests the information from the process inside the container. The proxy will also handle the response to the client.

If you simply want to change some headers, a default setup of an apache reverse proxy might be enough. See this link on how to set up a reverse proxy using apache:

https://www.digitalocean.com/community/tutorials/how-to-use-apache-http-server-as-reverse-proxy-using-mod_proxy-extension

Other proxy technologies you might consider: - Nginx - HAProxy

If you want to do more than just changing headers (please fill me in!) than you might have to write some code to handle that for you.

Good luck! And let me know if you need more help!

like image 142
RoyB Avatar answered Oct 13 '22 20:10

RoyB


Something like mitmproxy. Docker does not change the approach.

like image 1
Bryan Avatar answered Oct 13 '22 21:10

Bryan