Skip to content

http-master and http-proxy templates for Node.js #3

@trusktr

Description

@trusktr

It'd be nice to add templates for http-master and http-proxy. They are Apache/Nginx-like tools for Node.js (perhaps easier to work with, it's just JS!).

For example, the config for http-proxy might look like

// -- ####### HTTPS PROXY SERVER #######
var fs = require("fs")

var files = [
    "/etc/letsencrypt/live/example.com/chain.pem",
]

var caChain = []

files.forEach(function(file) {
    caChain.push(fs.readFileSync(file))
})

var httpsOptions = {
    https: {
        ca: caChain,
        key: fs.readFileSync('/etc/letsencrypt/live/example.com/privkey.pem', 'utf8'),
        cert: fs.readFileSync('/etc/letsencrypt/live/example.com/cert.pem', 'utf8')
    },
    router: {
        'example.com': '127.0.0.1:5678', // map a domain to a local service
        // ... etc ...
    }
    // ... other options ...
}

var httpsProxyServer = httpProxy.createServer(httpsOptions, function(request, response, proxy) {
    // do whatever you need with the request and response objects, f.e. redirect certain paths to another domain, etc.
})

httpsProxyServer.listen(443) // listen on the standard HTTPS port.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions