work

switch

SpiderMonkeyBashOpen SourceES6GulpTravis CIBabelMochaChaiSinonHandlebarsIsparta

Switch provides a quick and easy way to use a common configuration file between Nginx and Apache, allowing a developer to toggle between web-server software without the need to rewrite conf files.

Try switch commands in this interactive terminalweb-user@lukejones.co:~ $

Man Page

Switch

Note: currently supported <app> options are either nginx or apache

Usage:
  switch help                   Show this message
  switch to <app>               Build conf file for the <app> specified and start the <app> service, catching any <app> errors
    --config <file>             Config file to be used to generate conf file. Default: <current directory>/.switchrc
    --out <file>                Output file. Default: /etc/nginx/sites-enabled/switch.conf, /etc/apache2/sites-enabled/switch.conf
    --source <file>             The Switch source directory, for current directory, use a period. Default: ~/.switch
    --print                     Display the generated conf without writing to the output file
  switch current                Display <app> currently being used

Example:
  switch to nginx              Generate nginx.conf and start the nginx service
  switch to apache --print     Display the generated apache.conf, without writing to file or starting apache

Example .switchrc File

{
  "example.com": {
    "port": 443,
    "ssl": {
      "enable": true,
      "cert": "/etc/ssl/cert.crt",
      "key": "/etc/ssl/cert.key"
    },
    "aliases": ["sub.example.com"],
    "accessLog": "/var/log/access.log",
    "errorLog": "/var/log/error.log",
    "root": "/var/www",
    "index": ["index.js"],
    "serverSignature": false,
    "listDirectories": false,
    "/": {
      "proxy": {
        "enable": true,
        "to": "http://localhost:3000"
      }
    },
    "/static": {
      "compress": {
        "enable": true,
        "types": ["text/plain", "application/javascript", "text/javascript", "text/css"]
      },
      "caching": {
        "enable": true,
        "types": ["js", "css", "html", "svg"],
        "expires": {
          "years": 1
        }
      },
      "headers": {
        "set": {
          "header-1": "1",
          "header-2": "2",
          "header-3": "3"
        },
        "unset": ["bad-header-1", "bad-header-2"]
      }
    }
  },
  "www.example.com": {
    "port": 80,
    "aliases": ["example.com"],
    "redirect": {
      "enable": true,
      "to": "https://example.com",
      "permanent": true
    }
  }
}