SecNex API Gateway

Go Version License

A high-performance, configurable API gateway built in Go with chi/v5 routing. Provides reverse proxy capabilities with path-based routing, prefix stripping, and structured logging.

Features

  • Reverse Proxy - Route requests to backend services via HTTP reverse proxy
  • Path-based Routing - Configurable route patterns with chi/v5 router
  • Prefix Stripping - Remove path prefixes before forwarding to backends
  • Host-based Routing - Virtual hosting support via host headers
  • Middleware Pipeline - Extensible middleware chain (request ID, real IP, logging)
  • Structured Logging - JSON logging with sensitive field pseudonymization

Quick Start

# Clone the repository
git clone https://git.secnex.io/secnex/gateway.git
cd gateway/app

# Run the gateway
go run main.go

The gateway loads configuration from ../gateway.yaml and starts on the configured host/port (default: 0.0.0.0:8080).

Health Check

curl http://localhost:8080/_/health

Returns 200 OK when the gateway is running.

Documentation

Example Configuration

gateway:
  host: "0.0.0.0"
  port: 8080
  features:
    - request_id
    - real_ip
    - logger
    - host

hosts:
  - id: "host-001"
    name: "localhost"
    domain: "localhost:8080"

targets:
  - id: "target-001"
    name: "httpbin"
    url: "https://httpbin.org"

apis:
  - id: "api-001"
    host: "host-001"
    target: "target-001"

routes:
  - id: "route-001"
    api: "api-001"
    path: "/api/v1/*"
    strip_prefix:
      enabled: true
      prefix: "/api/v1"

Project Structure

app/
├── main.go           # Entry point
├── config/           # Configuration loading
├── server/           # Gateway, routes, proxy
├── middlewares/      # HTTP middleware
└── utils/            # Utility functions

Requirements

  • Go 1.25.5 or later

License

This project is licensed under the MIT License - see the LICENSE file for details.


Made with ❤️ by SecNex

Description
No description provided
Readme MIT 89 KiB
Languages
Go 95.8%
Dockerfile 2.3%
Python 1.9%