2018-08-17 00:39:01 +08:00
|
|
|
# secure
|
2018-08-19 17:02:20 +08:00
|
|
|
Single-minded HTTPS reverse proxy
|
2018-08-17 00:39:01 +08:00
|
|
|
|
|
|
|
## Overview
|
|
|
|
TODO
|
|
|
|
|
|
|
|
## Motivation
|
|
|
|
I wanted HTTPS for `godoc -http :6060`.
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
```
|
2018-08-18 00:03:05 +08:00
|
|
|
usage: secure [-addr host:port] -cert certfile -key keyfile upstream
|
|
|
|
-addr string
|
|
|
|
listen address (default ":443")
|
|
|
|
-cert string
|
|
|
|
path to cert file
|
|
|
|
-key string
|
|
|
|
path to key file
|
|
|
|
upstream string
|
|
|
|
upstream url
|
|
|
|
```
|
|
|
|
|
|
|
|
### Example
|
|
|
|
```
|
|
|
|
secure -cert cert.pem -key key.pem http://localhost:6060
|
2018-08-17 00:39:01 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
## Demo
|
|
|
|
*nix:
|
|
|
|
```
|
2018-08-18 00:03:05 +08:00
|
|
|
# generate self-signed certificate and private key
|
2018-08-17 00:39:01 +08:00
|
|
|
openssl req -newkey rsa:4096 -nodes -keyout key.pem -x509 -days 365 -out cert.pem -subj "/CN=localhost"
|
|
|
|
|
|
|
|
# start godoc
|
|
|
|
godoc -http localhost:6060 &
|
|
|
|
|
|
|
|
# secure it
|
2018-08-18 00:03:05 +08:00
|
|
|
secure -key key.pem -cert cert.pem http://localhost:6060
|
2018-08-17 00:39:01 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
Windows (PowerShell)
|
|
|
|
```
|
|
|
|
# somehow obtain key.pem and cert.pem
|
|
|
|
|
|
|
|
# start godoc
|
2018-08-18 00:03:05 +08:00
|
|
|
# Command Prompt: start godoc -http localhost:6060
|
2018-08-17 00:39:01 +08:00
|
|
|
Start-Process godoc "-http localhost:6060"
|
|
|
|
|
|
|
|
# secure it
|
2018-08-18 00:03:05 +08:00
|
|
|
secure -key key.pem -cert cert.pem http://localhost:6060
|
2018-08-17 00:39:01 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
## Features
|
|
|
|
- [x] TLS termination proxy
|
|
|
|
- [ ] Redirect HTTP to HTTPS
|
2018-08-18 00:06:34 +08:00
|
|
|
- [ ] Config file support
|
|
|
|
- [ ] Rudimentary logging
|