SSL for web backend

This commit is contained in:
emile 2015-09-22 21:00:29 +02:00
parent 7e62c7323c
commit e4159564ca
3 changed files with 23 additions and 1 deletions

View file

@ -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)

View file

@ -66,6 +66,13 @@
#
# address = ":8080"
# SSL certificate and key used
#
# Optional
#
# CertFile = "traefik.crt"
# KeyFile = "traefik.key"
################################################################
# File configuration backend

9
web.go
View file

@ -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) {