Work as a standalone server
Closed, ResolvedPublic



A reverse proxy in front of WriteFreely isn't required, so we should support and encourage running the app without one, as well.


Replace "Port" configuration step with a new one:

- Development
- Production, standalone
- Production, reverse proxy

If Development is chosen, ask for the Port. Otherwise set new config option config.ServerCfg.Standalone to true if standalone is chosen.

If standalone is chosen, prompt for:

Server mode:
- Insecure (port 80)
- Secure (port 443)
- Save & Quit
- Quit

Set Port based on previous response. If Secure is chosen, prompt for:

  • config.ServerCfg.TLSCertPath
  • config.ServerCfg.TLSKeyPath

In the app:

if app.cfg.Server.Standalone && app.cfg.Server.TLSCertPath != "" && app.cfg.Server.TLSKeyPath != "" {
  go http.ListenAndServe(":80", http.HandlerFunc(func (w http.ResponseWriter, r *http.Request) {
    http.Redirect(w, r, app.cfg.App.Host+r.URL.String(), http.StatusMovedPermanently)
  http.ListenAndServeTLS(":443", app.cfg.Server.TLSCertPath, app.cfg.Server.TLSKeyPath, nil)
} else {
  // ... current ListenAndServe code

Event Timeline

matt created this object with visibility "Public (No Login Required)".
matt created this object with edit policy "WriteFreely (Project)".
matt updated the task description. (Show Details)

Is served by Nginx, Apache, or something like that? I noticed that reports that HTTP2 is not enabled, but should be a one-line fix in Nginx config or there's the more bleeding-edge approach 😉