Hi Idegen,

I’ve been looking around for a convenient tool in order to check the status of my proxy.pac / wpad.dat rules, and I found a very nice self hosted solution…

Well, this is the web application I found out – https://github.com/jhthorsen/app-proxyforurl . To go straight to the point, the developer is kind enough to host an online version that you can check on your own here: https://thorsenlabs.com/pac

In what regards me, I wanted to have that hosted locally on a Linux based Docker system. To make it a bit funnier, that system has no default gateway and it’s only outbound possible path is through, you’ve guessed it, a Proxy server.

Hence, here is what I’ve done in order to successfully compile the needed image:

git clone https://github.com/jhthorsen/app-proxyforurl.git
cd app-proxyforurl/

Then I’ve updated the Dockerfile like this (saving a copy of the original before is not a bad idea):

# jhthorsen/app-proxyforurl
#
# BUILD: docker build --no-cache --rm -t jhthorsen/app-proxyforurl .
# RUN:   docker run -it --rm -p 8080:8080 jhthorsen/app-proxyforurl
FROM alpine:3.5
MAINTAINER jhthorsen@cpan.org

ENV HTTP_PROXY="http://10.10.10.10:8080/"
ENV http_proxy="http://10.10.10.10:8080/"
ENV HTTPS_PROXY="http://10.10.10.10:8080/"
ENV https_proxy="http://10.10.10.10:8080/"
ENV ALL_PROXY="http://10.10.10.10:8080/"
ENV all_proxy="http://10.10.10.10:8080/"

RUN apk add --no-cache curl openssl perl perl-io-socket-ssl perl-net-ssleay wget \
 && apk add --no-cache --virtual builddeps build-base perl-dev \
 && curl --proxy "http://10.10.10.10:8080" -L https://github.com/jhthorsen/app-proxyforurl/archive/main.tar.gz | tar xvz \
 && curl --proxy "http://10.10.10.10:8080" -L https://cpanmin.us | perl - App::cpanminus \
 && cpanm -M https://cpan.metacpan.org --installdeps ./app-proxyforurl-main \
 && apk del builddeps \
 && rm -rf /root/.cpanm /var/cache/apk/*

ENV MOJO_MODE production
ENV PROXYFORURL_TEMPLATES=/templates

EXPOSE 8080

ENTRYPOINT ["/app-proxyforurl-main/script/proxyforurl", "prefork", "-l", "http://*:8080"]

With these changes, we should be ready to build the Docker image itself:

docker image build --build-arg all_proxy=http://10.10.10.10:8080/ -t proxyforurl .

Finally, creating and booting a container based on that image:

docker container create \
  --name proxyforurl \
  -p 10.10.10.11:8080:8080 \
  --dns 10.10.10.10 \
  -it proxyforurl:latest

docker container start proxyforurl

And there you go, a locally hosted proxy PAC file parser:

Thank you Mister Jan Henning Thorsen!!

Hope this might help some of you..
So longue,
Obuno

— UPDATE —

I’ve now shifted such workloads behind an Docker nginx reverse proxy providing simple SSL/TLS management etc… Here is what you’d need to correctly host this app using x-forwarded-for client real IP’s:

# jhthorsen/app-proxyforurl
#
# BUILD: docker build --no-cache --rm -t jhthorsen/app-proxyforurl .
# RUN:   docker run -it --rm -p 8080:8080 jhthorsen/app-proxyforurl
FROM alpine:3.5
MAINTAINER jhthorsen@cpan.org

ENV HTTP_PROXY="http://10.10.10.10:8080/"
ENV http_proxy="http://10.10.10.10:8080/"
ENV HTTPS_PROXY="http://10.10.10.10:8080/"
ENV https_proxy="http://10.10.10.10:8080/"
ENV ALL_PROXY="http://10.10.10.10:8080/"
ENV all_proxy="http://10.10.10.10:8080/"

RUN apk add --no-cache curl openssl perl perl-io-socket-ssl perl-net-ssleay wget \
 && apk add --no-cache --virtual builddeps build-base perl-dev \
 && curl -L https://github.com/jhthorsen/app-proxyforurl/archive/main.tar.gz | tar xvz \
 && curl -L https://cpanmin.us | perl - App::cpanminus \
 && cpanm -M https://cpan.metacpan.org --installdeps ./app-proxyforurl-main \
 && apk del builddeps \
 && rm -rf /root/.cpanm /var/cache/apk/*

# IF running behind reverse proxy, this is needed
ENV MOJO_REVERSE_PROXY=1

ENV MOJO_MODE production
ENV PROXYFORURL_TEMPLATES=/templates
ENV PROXYFORURL_BRAND_NAME=Woopsi-Doopsi
ENV PROXYFORURL_BRAND_URL=https://proxyforurl.host.local


EXPOSE 8080

ENTRYPOINT ["/app-proxyforurl-main/script/proxyforurl", "prefork", "-l", "http://*:8080"]

According to my readings , the MOJO_REVERSE_PROXY environment variable set within the container instruct’s Mojolicious to automatically pick up the X-Forwarded-For and X-Forwarded-Proto headers. That’s it =)