-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
58 lines (41 loc) · 1.15 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package main
import (
"github.com/jonasroussel/hyve/acme"
"github.com/jonasroussel/hyve/servers"
"github.com/jonasroussel/hyve/stores"
"github.com/jonasroussel/hyve/tools"
)
func main() {
// Load environment variables
tools.LoadEnv()
// Load store
stores.Load()
// Load or create Let's Encrypt user
acme.LoadOrCreateUser()
// Init lego
acme.InitLego()
// Load dynamic target
tools.LoadDynamicTarget()
// Create TLS server
tlsListener, tlsServer, tlsHandler := servers.NewTLS()
// Create HTTP server
httpListener, httpServer, httpHandler := servers.NewHTTP()
// Add the admin api to the TLS handler
servers.AdminAPI(tlsHandler)
// Add the reverse proxy to the TLS handler
servers.ReverseProxy(tlsHandler)
// Add the HTTP-01 challenge solver to the HTTP handler
servers.HTTP01ChallengeSolver(httpHandler)
// Add the redirect to HTTPS handler
servers.RedirectToHTTPS(httpHandler)
// Start TLS server
go tlsServer.Serve(tlsListener)
// Start HTTP server
go httpServer.Serve(httpListener)
// Register admin domain if needed
acme.RegisterAdminDomain()
// Activate auto renew
acme.ActivateAutoRenew()
// Wait for shutdown
select {}
}