SSL for web backend
This commit is contained in:
parent
7e62c7323c
commit
e4159564ca
3 changed files with 23 additions and 1 deletions
|
@ -202,7 +202,15 @@ To enable it:
|
|||
```toml
|
||||
[web]
|
||||
address = ":8080"
|
||||
|
||||
# SSL certificate and key used
|
||||
#
|
||||
# Optional
|
||||
#
|
||||
# CertFile = "traefik.crt"
|
||||
# KeyFile = "traefik.key"
|
||||
```
|
||||
|
||||
* ```/```: provides a simple HTML frontend of Træfik
|
||||
|
||||
![HTML frontend](img/web.frontend.png)
|
||||
|
|
|
@ -66,6 +66,13 @@
|
|||
#
|
||||
# address = ":8080"
|
||||
|
||||
# SSL certificate and key used
|
||||
#
|
||||
# Optional
|
||||
#
|
||||
# CertFile = "traefik.crt"
|
||||
# KeyFile = "traefik.key"
|
||||
|
||||
|
||||
################################################################
|
||||
# File configuration backend
|
||||
|
|
9
web.go
9
web.go
|
@ -11,6 +11,7 @@ import (
|
|||
|
||||
type WebProvider struct {
|
||||
Address string
|
||||
CertFile, KeyFile string
|
||||
}
|
||||
|
||||
type Page struct {
|
||||
|
@ -43,7 +44,13 @@ func (provider *WebProvider) Provide(configurationChan chan<- *Configuration) {
|
|||
systemRouter.Methods("GET").Path("/api/frontends/{frontend}").Handler(http.HandlerFunc(GetFrontendHandler))
|
||||
systemRouter.Methods("GET").PathPrefix("/static/").Handler(http.StripPrefix("/static/", http.FileServer(&assetfs.AssetFS{Asset: Asset, AssetDir: AssetDir, Prefix: "static"})))
|
||||
|
||||
go http.ListenAndServe(provider.Address, systemRouter)
|
||||
go func() {
|
||||
if len(provider.CertFile) > 0 && len(provider.KeyFile) > 0 {
|
||||
http.ListenAndServeTLS(provider.Address,provider.CertFile, provider.KeyFile, systemRouter)
|
||||
} else {
|
||||
http.ListenAndServe(provider.Address, systemRouter)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
func GetConfigHandler(rw http.ResponseWriter, r *http.Request) {
|
||||
|
|
Loading…
Reference in a new issue