How to duplicate traffic using http proxy


I am using caddy as reverse proxy on my server. What I am trying to do now, is that when the proxy recieves an http request, it has to act as a proxy as usuail sending it to the corresponding service (Service A) but in addition, I want to send the same request to anoher service (Service B). I don’t need to keep the response from Service B since this is just for testing purposes.

I tried several things on my caddyfile. What I have now is: {
	proxy / {
		upstream localhost:8500 (this is Service A)
        upstream localhost:8501 (this is Service B)

I tried to duplicate the whole proxy block (one for each service) and I also tried to put a single upstream using port ranges instead of putting it twice, but nothing works. It sends the request to one service or another, but never at both.

Do you know how can I do this or what I am doing wrong?

Thank you!

Interesting… is this for logging purposes or something?

What should be done with the response? Just discard it? Or close it right away and not even read it?

Also, this might be better as a feature request on GitHub so we don’t lose track of it.

In my case is a workaround to test new features of a service with real traffic. In fact, Service B is a new version of Service A, and Service A is the “production” version. So with this I can test new features with real cases.

About the responses, in my case I don’t need them because my service just takes the information from te reqeust, make some calcs and take some actions, but nothing is returned to the user. Anyway, for a generic case, maybe the responses should be stored somewhere or maybe logged.

It this possible to do right now? Do you need me to create an issue in github explaining this case?

I don’t believe it is right now, no. Yes, could you please open an issue? Then we can track it and that would be very helpful!

Also, pull requests welcomed, to make it happen sooner. :slight_smile: (Make sure it targets the v2 branch.)

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.