tonto

Tonto.js: Apache Config File Generator

npm install tonto
2 downloads in the last week
2 downloads in the last month
 _____ ___  _  _ _____ ___
|_   _/ _ \| \| |_   _/ _ \
  | || (_) | .` | | || (_) |
  |_| \___/|_|\_| |_| \___/.JS
 APACHE CONFIG FILE GENERATOR

Build Status Coverage Status Code Climate

Generate Apache Config Files With Tonto.js!

Wait.. What? Why?!

Because sometimes, templates either don't cut it, or you get sick of setting up templates. Behold: Tonto.js with support for 591 apache directives, without leaving the comfort of your Javascript couch.

The Tonto Name

The Tonto (Dilzhę́’é) people are one of the Western Apache groups from North America. Long ago, their enemies called them "foolish", "wild", "crazy", and "those who you don't understand" for speaking and doing things differently than their neighbors. Today they are know throughout art communities for their superior fine crafting.

Use Case Examples

  1. Server hosts can write a deployment script with Tonto.js to easily customize apache config files for new machines.
  2. Wrap this library with your own to provide an easy interface for generating all of your project's apache configs.
  3. Take your wife out for a nice steak dinner, then to a show that she wants to see. Tell her it was all made possible because you're smart and made time for her with Tonto.js.

Using Tonto.js

var Tonto = require('../'),
    tonto = new Tonto();

tonto.virtualHost('*:443', function (subDirectives) {

    'use strict';

    subDirectives
        .serverName('somesite.com')
        .header('set Access-Control-Allow-Origin "*"')

        .directory('/var/node/somesite/current/public/', function (directoryDirectives) {
            directoryDirectives
                .addOutputFilterByType('DEFLATE text/html text/plain text/xml text/css text/javascript application/x-javascript')
                .browserMatch('\\bMSIE\\s6 no-gzip')
                .options('FollowSymLinks')
                .options('-MultiViews')
                .allowOverride('none')
                .order('allow, deny')
                .allow('from all');
        })

        .proxyPass('/ http://localhost:8080')
        .proxyPassReverse('/ http://localhost:8080')

        .sslcertificateFile('/var/node/myApp/certificates/somehost_com.crt')
        .sslcertificateKeyFile('/var/node/myApp/certificates/somehost_com.key')
        .sslcertificateChainFile('/var/node/myApp/certificates/somehost_com_DigiCertCA.crt');

});

tonto.virtualHost('*:80', function (subDirectives) {

    'use strict';

    subDirectives
        .serverName('somesite.com')
        .rewriteEngine('On')
        .rewriteBase('/myapp')
        .rewriteCond('%{HTTPS off}')
        .rewriteRule('(.*) http://somesite.com%{REQUEST_URI}');

});

console.log(tonto.render());
npm loves you