A simple Go-based forward proxy that redirects incoming HTTP requests to a specified destination URL.
- Supports HTTPS forwarding with self-signed certificates.
- Customizable target URL via environment variables.
- Dockerized deployment with
docker-compose
. - Automated SSL certificate generation if missing.
# Build and run the container
docker-compose up --build -d
Ensure you have Go installed, then:
go mod tidy
go build -o go-forward-proxy .
./go-forward-proxy
The proxy can be configured via environment variables:
TARGET_URL
: The destination URL to which requests will be forwarded.
- Uses
golang:1.23
as the base image. - Installs OpenSSL and CA certificates.
- Builds the Go binary and ensures execution permissions.
- Uses an
entrypoint.sh
script to handle SSL certificate generation dynamically.
This script checks for existing SSL certificates and generates new ones if missing.
Defines a service proxy
that:
- Builds the image from the Dockerfile.
- Exposes port
2020
mapped to the application's internal port1010
. - Uses
TARGET_URL
as an environment variable.
Once the proxy is running, you can test it by sending a request:
curl -k https://localhost:2020
This project is licensed under the MIT License.