This project is a reverse proxy server designed for home networks with a single IP address. It allows routing to multiple services hosted within the internal network. The server uses Let's Encrypt to generate SSL certificates for each host address and redirects HTTP traffic to HTTPS.
- Reverse Proxy: Routes incoming requests to the appropriate backend service based on the host address.
- Let's Encrypt Integration: Automatically generates and renews SSL certificates for each host address.
- HTTP to HTTPS Redirection: Redirects all HTTP traffic to HTTPS to ensure secure communication.
The server configuration is defined in the config.yaml file. The configuration file should specify the services to be proxied, including their host addresses and backend URLs.
Example config.yaml:
services:
- host: example1.com
backend: http://localhost:8081
- host: example2.com
backend: http://localhost:8082-
Install Dependencies: Ensure you have Go installed and run
go mod tidyto install the required dependencies. -
Run the Server: Start the reverse proxy server by running the following command:
go run main.go serve or go build *.go ./main serve -
Access Your Services: Access your services using the configured host addresses. The server will handle the routing and SSL termination.
- Configuration Loading: The
LoadConfigfunction incmd/proxy.goreads the configuration fromconfig.yamland unmarshals it into aConfigstruct. - Reverse Proxy Creation: The
NewReverseProxyfunction incmd/proxy.gocreates a new reverse proxy for a given target URL. - Server Initialization: The
startProxyServerfunction incmd/proxy.goinitializes and starts the HTTP and HTTPS servers, sets up the Let's Encrypt manager, and handles the routing logic.
This project is licensed under the MIT License. See the LICENSE file for details.
- Cobra for command-line interface support.
- Let's Encrypt for providing free SSL certificates.
- Go for the programming language and standard library.