Dockered tinyproxy for dev environment

The other day I was looking for a solution to replace my Charles based proxy setup for our legacy system’s dev environment. Mostly because a colleague doesn’t have a license and didn’t want to pay for it. And we’re only using it for a single use case. The functionality they call “Map Remote”. Basically it redirects calls to remote services to some other other service making it look like it’s the original system. Ideal for a development system where you can’t just change hostnames (for reasons…).

So what I want to do, I want to type in my browser and not end up at the actual live system but instead on services running locally on my computer.

We’ve switched to using docker, so running them locally is a breeze anyway already. So why not just add another docker component that acts as a proxy and does that job for me? I’d then just have to change settings in my browser to make it use that proxy and here I go.
After a short search on duckduckgo I’ve found tinyproxy and after inspecting it a bit deeper I found a way to make it work for me the way I wanted.
Here’s the Dockerfile I came up with, just change the hostnames that suit you and you’re all set.

FROM alpine
MAINTAINER Stefan Strigler 

RUN apk add --no-cache tinyproxy

RUN { \
    echo 'upstream web_app:80 ""'; \
    echo 'upstream web_app:80 ""'; \
    echo 'upstream some_other:80 ""'; \
    } >> /etc/tinyproxy/tinyproxy.conf

RUN sed -i 's/^Allow/\#Allow/' /etc/tinyproxy/tinyproxy.conf


ENTRYPOINT /usr/sbin/tinyproxy -d

Since it’s based on alpine the whole image is only less than 5MB. Crazy!

I then added it to our docker-compose.yml like

version: '2'

  web_app: ...

  some_other: ...

    image: steve/tinyproxy
      - 8888:8888
      - web_app
      - some_other

and off we go.

Comments are closed