From 467006aabcaae3d07f21a33b25edea1b8241cf3e Mon Sep 17 00:00:00 2001 From: "Kelvin Ly (on the cloud)" Date: Fri, 28 Sep 2018 22:41:31 +0000 Subject: [PATCH] Fix service file slightly, use let's encrypt to get a certificate --- .gitignore | 1 + install.sh | 3 +++ kelvinly-server.service | 1 + main.go | 4 ++++ 4 files changed, 9 insertions(+) diff --git a/.gitignore b/.gitignore index 5b301f7..a051929 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ kelvinly-server +*.pem diff --git a/install.sh b/install.sh index ef66e19..e05c8a9 100755 --- a/install.sh +++ b/install.sh @@ -17,3 +17,6 @@ source ~/.bashrc go get -u gopkg.in/russross/blackfriday.v2 go get -u github.com/shurcooL/github_flavored_markdown go get -u github.com/sevlyar/go-daemon + +sudo apt-get install certbot -t stretch-backports +mkdir -p certbot-tmp diff --git a/kelvinly-server.service b/kelvinly-server.service index bdeb560..3ce5974 100644 --- a/kelvinly-server.service +++ b/kelvinly-server.service @@ -3,6 +3,7 @@ Description=My main HTTP server After=network.target syslog.target [Service] +User=kelvin Type=forking PIDFile=/tmp/kelvinly-server-pid ExecStart=/home/kelvin/kelvinly-server/kelvinly-server diff --git a/main.go b/main.go index 33bda04..eb29bd6 100644 --- a/main.go +++ b/main.go @@ -38,6 +38,9 @@ const HTML_HEADER = ` ` const HTML_FOOTER = ` + ` @@ -157,6 +160,7 @@ func startServer(srv *http.Server) { log.Print("installing handlers") serveMux := http.NewServeMux() serveMux.HandleFunc("/", rootHandler) + //serveMux.Handle("/certbot/", http.StripPrefix("/certbot/", http.FileServer(http.Dir("./certbot-tmp")))) serveMux.Handle("/gfm/", http.StripPrefix("/gfm", http.FileServer(gfmstyle.Assets))) serveMux.HandleFunc("/main.css", func(w http.ResponseWriter, r *http.Request) { http.ServeFile(w, r, "main.css") })