real-ip-request-printer/README.md

58 lines
1.8 KiB
Markdown
Raw Permalink Normal View History

2024-11-08 17:23:44 +03:00
# 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` and `X-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](https://golang.org/dl/) (for local builds)
- [Docker](https://www.docker.com/get-started) and [Docker Compose](https://docs.docker.com/compose/)
### Running Locally
1. Clone the repository:
```sh
git clone https://github.com/yourusername/real-ip-request-printer.git
cd real-ip-request-printer
```
2. Build and run the Go application:
```sh
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:
```sh
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:
```sh
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](LICENSE.md).