Table of Contents | ||
---|---|---|
|
Overview
The Gateway Proxy is a standalone application to be deployed separately. The proxy enables communication to an outbound server through it's REST API. If a request is send to it’s endpoint it will forward the request to upstream servers.
...
By default the proxy only works for outbound connections to URLs configured in the connection-routing-yml
file. All other requests are blocked. Setting the environment variable PROXY_ALLOW_UNKNOWN_TARGETs
to true
allows requests to be proxied to all target URLs.
Logging verbosity
Logging verbosity can be controlled by an environment variable called PROXY_GATEWAY_LOG_LEVEL
. Set this to DEBUG
for full verbosity and to INFO
for more concise logging output.
Running the Java application
After building the Gateway Proxy it can be started using the jar file built in the previous step:
Code Block |
---|
#> java -jar target/smartfacts-gateway-proxy-<version>.jar |
Running the Docker Container
The application is also provided as a docker container at registry.mid.de/smartfacts/smartfacts-gateway-proxy:latest
and can be started using the docker-compose.yml
file in the root directory of this project. The docker compose file is configured to run the application on port 8418 on the host machine. In order to supply a custom connection-routing.yml
configuration file they can be mounted s volumes in the root directory of the docker image.
Logging verbosity
Logging verbosity can be controlled by an environment variable called PROXY_GATEWAY_LOG_LEVEL
. Set this to DEBUG
for full verbosity and to INFO
for more concise logging output.
...
Proxy HTTP endpoint
The proxy application exposes endpoints the endpoint /proxy/stream
to relay HTTP GET, POST, PUT, DELETE, PATCH and HEAD requests. Only requests to outbound servers that are configured in the connection-routing.yml
configuration file are allowed by default. This behavior can be controlled by the environment variable PROXY_ALLOW_UNKNOWN_TARGETS
.
...
Request sent to the endpoint /proxy/stream
with a Request Parameter named target
are proxied. The target
request parameter has to be set to an outbound
server URL. The outbound server URL has to be url encoded. Responses from the outbound server are streamed through the proxy back to the user-agent.
Examples
Proxy a GET request to
http://example.com/foo
:Code Block #> curl -X GET http://proxy.host/proxy/stream?target=http%3a%2f%2fexample.com/foo
Proxy a Post request with a JSON body to
http://example.com/bar
:Code Block #> curl -X POST -H "Content-Type: appliction/json" -d '{"my-data": "baz"}' http://proxy.host/proxy/stream?target=http%3a%2f%2fexample.com/bar
...