Page MenuHomeWrite.as

Work as a standalone server
Closed, ResolvedPublic

Description

Overview

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

Implementation

Replace "Port" configuration step with a new one:

Environment:
- 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)