This is an example of using the Apache Camel integration framework to create a HTTP proxy using the Camel Netty component.
Any request that is received using the HTTP PROXY protocol, i.e specifying the absolute form for the request target will be forwarded to the target service with the HTTP body converted to uppercase. The response from the target service will be processed by converting it to uppercase and returned to the client.
The support for HTTP over TLS (https
) protocol is available if Java Keystore
file is mounted at /tls/keystore.jks
(with password changeit
). The
implementation doesn't support HTTPS proxy tunneling via CONNECT
, the
request needs to be issued same as it is issued for the HTTP PROXY, the only
added benefit is that the request can be made over TLS.
If /tls/keystore.jks
exists then the listening port changes to 8443
.
To build the Docker image execute:
$ docker build -t camel-netty-proxy .
To run the Docker image execute:
$ docker run --rm -p 8080:8080 camel-netty-proxy
To test using curl
set the http_proxy
environment variable, for example:
$ http_proxy=http://localhost:8080 curl -v http://neverssl.com
To run on openshift, log in via the oc login
command to the OpenShift cluster
and position yourself in the project of choice using oc project <project>
and
run:
$ ./mvnw -Popenshift package
When running on OpenShift the service listens on port 8443 with TLS enabled. The certificate is issued by the OpenShift CA.