Feature: URL Prefix support (#181) (#185)

Usable when service is behind a proxy.
Tested with docker-distribution and apache httpd.
diff --git a/auth_server/server/config.go b/auth_server/server/config.go
index 391fa9f..427b9c1 100644
--- a/auth_server/server/config.go
+++ b/auth_server/server/config.go
@@ -48,6 +48,7 @@
 
 type ServerConfig struct {
 	ListenAddress string            `yaml:"addr,omitempty"`
+	PathPrefix    string            `yaml:"path_prefix,omitempty"`
 	RealIPHeader  string            `yaml:"real_ip_header,omitempty"`
 	RealIPPos     int               `yaml:"real_ip_pos,omitempty"`
 	CertFile      string            `yaml:"certificate,omitempty"`
@@ -78,6 +79,9 @@
 	if c.Server.ListenAddress == "" {
 		return errors.New("server.addr is required")
 	}
+	if c.Server.PathPrefix != "" && !strings.HasPrefix(c.Server.PathPrefix, "/") {
+		return errors.New("server.path_prefix must be an absolute path")
+	}
 
 	if c.Token.Issuer == "" {
 		return errors.New("token.issuer is required")
diff --git a/auth_server/server/server.go b/auth_server/server/server.go
index 5f0fa24..75dffba 100644
--- a/auth_server/server/server.go
+++ b/auth_server/server/server.go
@@ -332,14 +332,15 @@
 
 func (as *AuthServer) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
 	glog.V(3).Infof("Request: %+v", req)
+	path_prefix := as.config.Server.PathPrefix
 	switch {
-	case req.URL.Path == "/":
+	case req.URL.Path == path_prefix + "/":
 		as.doIndex(rw, req)
-	case req.URL.Path == "/auth":
+	case req.URL.Path == path_prefix + "/auth":
 		as.doAuth(rw, req)
-	case req.URL.Path == "/google_auth" && as.ga != nil:
+	case req.URL.Path == path_prefix + "/google_auth" && as.ga != nil:
 		as.ga.DoGoogleAuth(rw, req)
-	case req.URL.Path == "/github_auth" && as.gha != nil:
+	case req.URL.Path == path_prefix + "/github_auth" && as.gha != nil:
 		as.gha.DoGitHubAuth(rw, req)
 	default:
 		http.Error(rw, "Not found", http.StatusNotFound)
diff --git a/examples/reference.yml b/examples/reference.yml
index 2cf4957..839f8c6 100644
--- a/examples/reference.yml
+++ b/examples/reference.yml
@@ -13,6 +13,9 @@
   # Address to listen on.
   addr: ":5001"
 
+  # URL path prefix to use.
+  path_prefix: ""
+
   # TLS options.
   #
   # Use specific certificate and key.