Passthru: Monitoring HTTP traffic via a very simple proxy implementation with Zuul

Passthru: Monitoring HTTP traffic via a very simple proxy implementation with Zuul

Once upon a time, there was a tool named TCPMon to inspect HTTP traffic, which was very handy for debugging web services(SOAP and other… Passthru: Monitoring HTTP traffic via a very simple proxy ... while implementing a Simple Proxy server using Spring Boot+Zuul +Kotlin. You can ...

Once upon a time, there was a tool named TCPMon to inspect HTTP traffic, which was very handy for debugging web services(SOAP and other HTTP services). Basically it acted as a proxy forwarding the traffic to the target service while recording requests / responses and displaying via a Swing UI. It was a lifesaver for many projects that I’ve worked in.

Unfortunately TCPMon is not maintained anymore and it’s not very convenient to use in a containerized environment. Moreover I couldn’t find a simple plug&play alternative for the same purpose . For sure proxies like Nginx or HAProxy can easily monitor and log requests, but I didn’t find them very handy to configure for development. (I also found the Lua config a bit daunting to be honest)

First Attempt: Servlet

So I decided to give a shot implementing a very simple proxy using Spring Boot+Kotlin. My initial idea was implementing a simple servlet to forward requests to a target host(which is passed as an environment variable, so it’d be easy to configure in a Docker compose environment as well). The servlet would log the requests to console while the traffic is passing through. That’s why I named it Passthru.

The Passthru Servlet was expected to process the incoming Http Request, recreating, dispatching, handling the response and logging handling all the encoding, headers, parameters and payload stuff. I wasn’t really comfortable with implementing all of l these by myself. These should be already solved by someone else who has more time and commitment than me.

Zuul Gateway

Therefore I continued to dig a little more and came across Zuul by Netflix. I heard Zuul as an API Gateway but did not have a chance to try. Basically Zuul is an application level gateway and fortunately has direct integration with Spring. Moreover, Zuul provides a RequestContext object that enables developers to store request scoped data (in a Thread Local object).

I created a PassthruContext classes to record request response info which are as follows:

All I need to do seemed so simple:

  1. Implement a pre-filter to intercept requests and record it in the context.
  2. Implement a post-filter to handle responses and record in the context.
  3. Log the PassthruContext (to the console)

Of course, it did not go as smoothly as I expected in the beginning. There were some hurdles that I had to tackle on the way. In the next sections I will go over the steps along with the glitches I had to address.

software-development netflix-zuul servlet spring-boot coding

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Offshore Software Development - Best Practices

To make the most out of the benefits of offshore software development, you should understand the crucial factors that affect offshore development.

5 Core Criteria for Selecting Software Development Company - TopDevelopers.co

Check out these five criteria for the selection of your software vendor, and you will never regret having the wrong quality product made for you.

Wrestling Betting Software Development | WWE Betting Software Developers

Wrestling betting software development solutions from expert Wrestling betting app and software development company delivers ultimate betting experience. Chat with us.

Developer Career Path: To Become a Team Lead or Stay a Developer?

For a developer, becoming a team leader can be a trap or open up opportunities for creating software. Two years ago, when I was a developer, ... by Oleg Sklyarov, Fullstack Developer at Skyeng company

Become a developer - software development is a unique field

Become a developer - read about why software development is an ideal career. Software development is a future-proof career that will be in demand.