A simple and flexible reverse proxy written in Go
- Lightweight and fast execution
- Simple configuration file (YAML)
- Static file hosting
- Fallback support
- Virtual host support
- Graceful shutdown
- Detailed access logs (nginx-compatible)
- Structured access logs (JSON)
- TLS/SSL support
- Trace ID support
- Timeout control
go get github.com/bmf-san/gondola
Download the latest binary from the Releases page.
docker pull bmf-san/gondola
docker run -v $(pwd)/config.yaml:/etc/gondola/config.yaml bmf-san/gondola
Usage: gondola [options]
Options:
-config string Path to configuration file (default: /etc/gondola/config.yaml)
-version Display version information
-help Show help
The following environment variables can override command line options:
GONDOLA_CONFIG
: Path to the configuration fileGONDOLA_LOG_LEVEL
: Log level (debug, info, warn, error)
Gondola handles the following signals:
SIGTERM
,SIGINT
: Graceful shutdownSIGHUP
: Reload configuration fileSIGUSR1
: Reopen access logs
proxy:
port: "8080"
read_header_timeout: 2000 # milliseconds
shutdown_timeout: 3000 # milliseconds
log_level: "info" # debug, info, warn, error
static_files:
- path: /public/
dir: /path/to/public
upstreams:
- host_name: api.example.com
target: http://localhost:3000
read_timeout: 5000 # milliseconds
write_timeout: 5000 # milliseconds
- host_name: web.example.com
target: http://localhost:8000
Basic startup:
gondola -config config.yaml
Start in debug mode:
GONDOLA_LOG_LEVEL=debug gondola -config config.yaml
Start with Docker:
docker run -v $(pwd)/config.yaml:/etc/gondola/config.yaml \
-p 8080:8080 \
bmf-san/gondola
Start with systemd:
[Unit]
Description=Gondola Reverse Proxy
After=network.target
[Service]
ExecStart=/usr/local/bin/gondola -config /etc/gondola/config.yaml
Restart=always
Environment=GONDOLA_LOG_LEVEL=info
[Install]
WantedBy=multi-user.target
Gondola outputs detailed access logs compatible with nginx.
- Client Information
remote_addr
: Client IP addressremote_port
: Client port numberx_forwarded_for
: X-Forwarded-For header
- Request Information
method
: HTTP method (GET, POST, etc.)request_uri
: Full request URIquery_string
: Query parametershost
: Host headerrequest_size
: Request size
- Response Information
status
: HTTP statusbody_bytes_sent
: Response body sizebytes_sent
: Total response sizerequest_time
: Request processing time (seconds)
- Upstream Information
upstream_addr
: Backend addressupstream_status
: Backend statusupstream_size
: Backend response sizeupstream_response_time
: Backend response time (seconds)
- Other Headers
referer
: Referer headeruser_agent
: User-Agent header
{
"level": "INFO",
"msg": "access_log",
"remote_addr": "192.168.1.100",
"remote_port": "54321",
"x_forwarded_for": "",
"method": "GET",
"request_uri": "/api/users",
"query_string": "page=1",
"host": "api.example.com",
"request_size": 243,
"status": "OK",
"body_bytes_sent": 1532,
"bytes_sent": 1843,
"request_time": 0.153,
"upstream_addr": "localhost:3000",
"upstream_status": "200 OK",
"upstream_size": 1532,
"upstream_response_time": 0.142,
"referer": "https://example.com",
"user_agent": "Mozilla/5.0 ...",
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}
We welcome issues and pull requests at any time.
Feel free to contribute!
Before contributing, please check the following documents:
If you like this project, consider sponsoring us!
Alternatively, giving us a star would be appreciated!
It helps motivate us to continue maintaining this project. :D
This project is licensed under the MIT License.
- Blog