Prints IP of the request as received from the client or reverse proxy & all the headers.
.gitignore | ||
compose.yaml | ||
Dockerfile | ||
go.mod | ||
LICENSE.md | ||
main.go | ||
README.md |
real-ip-request-printer
Overview
real-ip-request-printer
is a simple Go service that listens for HTTP GET
requests on the root endpoint (/
) and responds with:
- The request IP address as seen by the application (considering headers like
X-Real-Ip
andX-Forwarded-For
). - All incoming HTTP headers in a
key: value
format.
This project is designed to help inspect and debug HTTP request information, particularly for applications deployed behind proxies or load balancers.
How to Run
Prerequisites
- Go (for local builds)
- Docker and Docker Compose
Running Locally
- Clone the repository:
git clone https://github.com/yourusername/real-ip-request-printer.git
cd real-ip-request-printer
- Build and run the Go application:
go mod tidy
go run main.go
The service will start on http://localhost:8080 by default. You can change the listening address by setting the LISTEN environment variable:
LISTEN=127.0.0.1:9090 go run main.go
Running with Docker
Change the hostname in the compose.yaml
to your domain. Build and run the Docker container using Compose:
docker compose up
Access the service via the configured domain.
Configuration
- The listening address of the Go service can be customized using the LISTEN environment variable.
- For containerized execution use Traefik for routing.
Project Structure
main.go
: The main Go application.Dockerfile
: Configuration for building the Docker image.compose.yaml
: Docker Compose configuration to run the service.README.md
: This documentation file.LICENSE.md
: License file..gitignore
: Standard git ignore settings for Go projects.
License
This project is open-source and available under the MIT License.