httpfork

HTTP/HTTPS reverse proxy which supports all methods and can ask Let's Encrypt certificates

Purchase a license

This means that:

Use cases

Imagine you have a VPS server and want to host there 2 web apps (written in Golang and delivered as binaries), and you want to have them on two different domain names on default port 443. The simplest way is to set up a nginx as a reverse proxy. But what if your apps use POST/PUT methods? nginx doesn’t support this so you can’t put them behind it. But now you have httpfork!

Also you can come up with other interesting use cases considering its possible options.

Config file

On the first run when there’s no configuration file, the program creates one filled with example data.

Example config:

{
  "port": 80,
  "sslPort": 443,
  "ssl": true,
  "certPath": "/opt/httpfork/certs",
  "autoCert": true,
  "skipHttp": false,
  "license": "ey...0ifX0=",
  "handlers": [
    {
      "host": "sub1.example.com",
      "path": "/",
      "url": "http://localhost:3010/"
    },
    {
      "host": "sub2.example.com",
      "path": "/",
      "url": "http://localhost:3020/"
    }
  ]
}

Also if a conf.d directory exists in current directory, it can contain *.json files with handler configurations in them like this:

{
  "host": "sub1.example.com",
  "path": "/",
  "url": "http://localhost:3010/"
}

and the handlers will be added to the current configuration.

Let’s take a closer look at this.

port

A port number to listen for HTTP. If omitted or is less than 1, the default value of 80 is used.

Not used if "ssl": true and "skipHttp": true.

sslPort

A port number to listen for HTTPS. If omitted or is less than 1, the default value of 443 is used.

Not used if "ssl": false.

ssl

If true, httpfork listens for HTTPS connections on sslPort. Default is false.

certPath

Path to certificates. If "autoCert": true, httpfork takes care about certificates by itself, it just stores them at the path. If "autoCert": false, you should provide with two files (*.crt and *.key) for each used domain. For instance, if you configure httpfork to process 2 domains: sub1.example.com and sub2.example.com, you should place 4 files (sub1.example.com.crt, sub2.example.com.crt containing certificates, and sub1.example.com.key, sub2.example.com.key containing secret keys). Format of the files is the same as for apache.

Not used if "ssl": false.

autoCert

If true, httpfork asks Let’s Encrypt for specified domain certificates.

Not used if "ssl": false.

skipHttp

If true and "ssl": true, httpfork listens for HTTPS only. If "autoCert": false it doesn’t listen for HTTP at all. If "autoCert": true it listens for HTTP only to correctly reply to Let’s Encrypt’s requests.

Not used if "ssl": false.

debug

If true, httpfork prints some debug info.

license

httpfork itself is a shareware so it requires license to be used. Use your license key or empty quotes for trial period. After the 30-day trial period you should buy a license at https://elfuego.biz.

handlers

handlers.host

Matches if host of incoming request equals to specified value. If "host": "", any host meets the condition.

handlers.path

Matches if path of incoming request equals to specified value.

handlers.url

If the request matches the handler condition, the value is used as the destination URL for the request.

systemd service

/etc/systemd/system/httpfork.service

[Unit]
Description=Httpfork Service

[Service]
Type=simple
WorkingDirectory=/etc/httpfork
ExecStart=/usr/local/bin/httpfork &
ExecStop=killall httpfork
TimeoutStartSec=0

[Install]
WantedBy=multi-user.target