https://github.com/razzie/razvhost
Virtual hosting/reverse proxy with TLS termination and automatic certificate management
https://github.com/razzie/razvhost
golang https reverse-proxy s3 tls-termination virtual-hosting
Last synced: about 2 months ago
JSON representation
Virtual hosting/reverse proxy with TLS termination and automatic certificate management
- Host: GitHub
- URL: https://github.com/razzie/razvhost
- Owner: razzie
- License: mit
- Created: 2020-04-16T02:11:49.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2025-01-12T17:16:23.000Z (about 1 year ago)
- Last Synced: 2025-01-12T18:26:30.576Z (about 1 year ago)
- Topics: golang, https, reverse-proxy, s3, tls-termination, virtual-hosting
- Language: Go
- Homepage:
- Size: 8.73 MB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# razvhost
Virtual hosting/reverse proxy with TLS termination and automatic certificate management
## Features
* Operation modes:
* Reverse proxy
* Redirect
* File and directory hosting
* Reading S3 buckets
* Reading SFTP directories
* PHP hosting (requires php-fpm)
* Go WebAssembly hosting
* Tailing log files
* HTTPS (TLS termination)
* HTTP2
* Automatic certificate management (from Let's Encrypt)
* Live config reload
* Supports all kinds of combinations of routes and target paths
* Supports [sprig](https://masterminds.github.io/sprig/) templates
* Load balancing
* Watching docker containers with VIRTUAL_HOST and VIRTUAL_PORT environment variables
* Configurable header discarding
* Request logging
## Configuration
By default razvhost tries to read configuration from `config` file in the working directory.
Alternatively you can specify the config file location with `-cfg ` command line arg.
An example configuration:
```
# comment
example.com alias.com {{env "ALIAS"}} -> http://localhost:8080
example.com/*/files -> file:///var/www/public/
loadbalance.com -> http://localhost:8081 http://localhost:8082
*.redirect.com -> redirect://github.com/razzie/razvhost
public-bucket.com -> s3://public-bucket/prefix?region=eu-central-1
private-bucket.com -> s3://key:secret@private-bucket/prefix?region=eu-central-1
mysftp.com -> sftp://user:pass@sftphost.com/dir
phpexample.com -> php:///var/www/index.php
phpexample2.com -> php:///var/www/mysite/
golang-project.com -> go-wasm:///path/to/build.wasm
kernel-logs-new.net -> tail-new:///var/log/kern.log
kernel-logs-all.net -> tail:///var/log/kern.log
```
## Build
You can either check out the git repo and build:
```Shell
git clone https://github.com/razzie/razvhost.git
cd razvhost
make
```
or use the **go** tool:
```Shell
go install github.com/razzie/razvhost/cmd/razvhost@latest
```
## Run
You don't need to run razvhost as root user, but you will need to set special capabilities on the binary to be able to bind 80 and 443 ports.
Use either `sudo setcap 'cap_net_bind_service=+ep' ./razvhost` or the existing setcap.sh helper in this repo: `sudo ./setcap.sh`
Command line args:
```
./razvhost -h
Usage of ./razvhost:
-certs string
Directory to store certificates in (default "certs")
-cfg string
Config file (default "config")
-debug string
Debug listener address, where hostname is the first part of the URL
-discard-headers string
Comma separated list of http headers to discard
-docker
Watch Docker events to find containers with VIRTUAL_HOST
-http2
Enable HTTP2
-no-server-header
Disable 'Server: razvhost/' header in responses
-nocert
Disable HTTPS and certificate handling
-php-addr string
PHP CGI address (default "unix:///var/run/php/php-fpm.sock")
```
If you intend to run razvhost using **supervisor**, here is an example configuration:
```INI
[program:razvhost]
command=/razvhost/razvhost -http2
user=
stderr_logfile=/var/log/supervisor/razvhost-err.log
stdout_logfile=/var/log/supervisor/razvhost-stdout.log
directory=/razvhost/
autostart=true
autorestart=true
```