Skip to content
Snippets Groups Projects
Commit f52e26a6 authored by Niall Sheridan's avatar Niall Sheridan
Browse files

Allow selecting which ip to listen on

parent 6bad2d07
No related branches found
No related tags found
No related merge requests found
......@@ -92,6 +92,7 @@ Configuration is divided into different sections: `server`, `auth`, `ssh`, and `
- `use_tls` : boolean. If set `tls_key` and `tls_cert` are required.
- `tls_key` : string. Path to the TLS key.
- `tls_cert` : string. Path to the TLS cert.
- `address` : string. IP address to listen on. If unset the server listens on all addresses.
- `port` : int. Port to listen on.
- `cookie_secret`: string. Authentication key for the session cookie.
- `http_logfile`: string. Path to the HTTP request log. Logs are written in the [Common Log Format](https://en.wikipedia.org/wiki/Common_Log_Format). If not set logs are written to stderr.
......
......@@ -371,7 +371,7 @@ func main() {
h := handlers.LoggingHandler(logfile, r)
fmt.Println("Starting server...")
l := fmt.Sprintf(":%d", config.Server.Port)
l := fmt.Sprintf("%s:%d", config.Server.Addr, config.Server.Port)
if config.Server.UseTLS {
log.Fatal(http.ListenAndServeTLS(l, config.Server.TLSCert, config.Server.TLSKey, h))
}
......
......@@ -4,6 +4,7 @@ server {
tls_key = "server.key" # Path to TLS key
tls_cert = "server.crt" # Path to TLS certificate
port = 443 # Port to listen on
address = "127.0.0.1" # Optional. IP address to listen on.
cookie_secret = "supersecret" # Authentication key for the client cookie
csrf_secret = "supersecret" # Authentication key for the CSRF token
http_logfile = "http.log" # Logfile for HTTP requests
......@@ -19,7 +20,7 @@ auth {
provider_opts {
domain = "example.com" # Oauth-provider specific options
}
users_whitelist = ["marco", "niall", "patrick"] # Optional
users_whitelist = ["marco@gmail.com", "niall@gmail.com", "patrick@gmail.com"] # Optional
}
# Configuration for the certificate signer.
......
......@@ -29,6 +29,7 @@ type Server struct {
UseTLS bool `mapstructure:"use_tls"`
TLSKey string `mapstructure:"tls_key"`
TLSCert string `mapstructure:"tls_cert"`
Addr string `mapstructure:"address"`
Port int `mapstructure:"port"`
CookieSecret string `mapstructure:"cookie_secret"`
CSRFSecret string `mapstructure:"csrf_secret"`
......
......@@ -21,6 +21,7 @@ func TestServerConfig(t *testing.T) {
a.Equal(server.TLSKey, "server.key")
a.Equal(server.TLSCert, "server.crt")
a.Equal(server.Port, 443)
a.Equal(server.Addr, "127.0.0.1")
a.Equal(server.CookieSecret, "supersecret")
}
......
......@@ -5,6 +5,7 @@ var ServerConfig = []byte(`
use_tls = true
tls_key = "server.key"
tls_cert = "server.crt"
address = "127.0.0.1"
port = 443
cookie_secret = "supersecret"
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment