diff --git a/server/root.Makefile b/server/root.Makefile index 05043987..d46af602 100644 --- a/server/root.Makefile +++ b/server/root.Makefile @@ -14,6 +14,9 @@ help: ## Print this help. deploy: /home/hmn/hmn/server/deploy.sh $1 +build: + sudo -u hmn --preserve-env=PATH bash -c "cd ~/hmn && go build -o /home/hmn/bin/hmn src/main.go" + edit-config: vim /home/hmn/hmn/src/config/config.go @echo 'Now that you have edited the config, you probably want to re-deploy the site:' @@ -21,7 +24,7 @@ edit-config: @echo ' make deploy' @echo '' -logs-hmn: ## View logs for the website +logs: ## View logs for the website journalctl -u hmn.service -f logs-caddy: ## View logs for Caddy diff --git a/server/serversetup.sh b/server/serversetup.sh index 8a798bbb..025a3070 100755 --- a/server/serversetup.sh +++ b/server/serversetup.sh @@ -135,7 +135,9 @@ SCRIPT fi # Set up SSH -if [ $checkpoint -lt 81] +if [ $checkpoint -lt 81 ]; then + set +x + do_as hmn <<'SCRIPT' ssh-keygen -t ed25519 -C "beta-server" -N "" -f ~/.ssh/gitlab git config --global core.sshCommand "ssh -i ~/.ssh/gitlab" @@ -253,9 +255,22 @@ ${BLUE_BOLD}Caddy${RESET}: /home/caddy/Caddyfile use when deploying. For example, a deployment of the beta site should use the 'beta' branch. -${BLUE_BOLD}Monit${RESET}: ~/.monitrc +${BLUE_BOLD}Website${RESET}: /home/hmn/hmn/src/config/config.go - Add the password for the email server. + First make sure you have Go on your path: + + source ~/.bashrc + + Then edit the config file using a special make task: + + make edit-config + + Fill out everything, then rebuild the site: + + make build + + You don't need to deploy the site yet; wait until you've + configured everything. ${BLUE_BOLD}Deploy Secret${RESET}: /home/hmn/hmn/server/deploy.conf @@ -267,16 +282,6 @@ ${BLUE_BOLD}Deploy Secret${RESET}: /home/hmn/hmn/server/deploy.conf Then, edit the above file and fill in the secret value from the GitLab webhook. -${BLUE_BOLD}Website${RESET}: /home/hmn/hmn/src/config/config.go - - Fill out everything :) - - Then rebuild the site: - - su hmn - cd ~/hmn - go build -o /home/hmn/bin/hmn src/main.go - ${BLUE_BOLD}Cinera${RESET}: /home/hmn/hmn/cinera/cinera.conf Add the correct domain. @@ -302,4 +307,6 @@ Then deploy the site: make deploy +Run 'make' on its own to see all the other tasks available to you! + HELP diff --git a/src/config/config.go.example b/src/config/config.go.example index e474e3b8..0578b141 100644 --- a/src/config/config.go.example +++ b/src/config/config.go.example @@ -39,8 +39,8 @@ var Config = HMNConfig{ AssetsSpacesRegion: "", AssetsSpacesEndpoint: "", AssetsSpacesBucket: "", - AssetsPathPrefix: "", - AssetsPublicUrlRoot: "", + AssetsPathPrefix: "", // Empty is fine for production, but may be necessary for dev + AssetsPublicUrlRoot: "", // e.g. "https://bucket-name.region.cdn.digitaloceanspaces.com/". Note the trailing slash... }, EpisodeGuide: EpisodeGuide{ CineraOutputPath: "./annotations/", diff --git a/src/website/requesthandling.go b/src/website/requesthandling.go index 0841571b..e7a9dea3 100644 --- a/src/website/requesthandling.go +++ b/src/website/requesthandling.go @@ -14,6 +14,7 @@ import ( "regexp" "strings" + "git.handmade.network/hmn/hmn/src/hmnurl" "git.handmade.network/hmn/hmn/src/logging" "git.handmade.network/hmn/hmn/src/models" "git.handmade.network/hmn/hmn/src/oops" @@ -252,7 +253,11 @@ func (c *RequestContext) Redirect(dest string, code int) ResponseData { } // Escape stuff - destUrl, _ := url.Parse(dest) + destUrl, err := url.Parse(dest) + if err != nil { + c.Logger.Warn().Err(err).Str("dest", dest).Msg("Failed to parse redirect URI") + return c.Redirect(hmnurl.BuildHomepage(), http.StatusSeeOther) + } dest = destUrl.String() res.Header().Set("Location", dest)