Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jupyterhub/configurable-http-proxy
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0.3.0
Choose a base ref
...
head repository: jupyterhub/configurable-http-proxy
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 0.4.0
Choose a head ref
  • 8 commits
  • 3 files changed
  • 2 contributors

Commits on Apr 29, 2015

  1. back to dev

    minrk committed Apr 29, 2015
    Copy the full SHA
    75de8b5 View commit details

Commits on May 6, 2015

  1. Copy the full SHA
    f04e72f View commit details
  2. Copy the full SHA
    6c0a58b View commit details

Commits on May 7, 2015

  1. Copy the full SHA
    98f1dbf View commit details
  2. Call the option redirect-port

    rgbkrk committed May 7, 2015
    Copy the full SHA
    296c01a View commit details
  3. Merge pull request #31 from rgbkrk/forward_80

    Flag and server for upgrading from 80 to https on host
    
    closes #30
    minrk committed May 7, 2015
    Copy the full SHA
    ac6de6d View commit details

Commits on Jun 4, 2015

  1. ignore dist

    minrk committed Jun 4, 2015
    Copy the full SHA
    52e3d79 View commit details
  2. release 0.4

    minrk committed Jun 4, 2015
    Copy the full SHA
    958a19b View commit details
Showing with 27 additions and 4 deletions.
  1. +1 −1 .gitignore
  2. +25 −2 bin/configurable-http-proxy
  3. +1 −1 package.json
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -6,4 +6,4 @@ node_modules
bench/env
bench/results
bench/html

dist
27 changes: 25 additions & 2 deletions bin/configurable-http-proxy
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ var fs = require('fs'),
log = require('winston');

args
.version('0.3.0')
.version('0.4.0')
// .option('-h', '--help', 'show help')
.option('--ip <n>', 'Public-facing IP of the proxy')
.option('--port <n>', 'Public-facing port of the proxy', parseInt)
@@ -25,6 +25,7 @@ args
.option('--api-ssl-key <keyfile>', 'SSL key to use, if any, for API requests')
.option('--api-ssl-cert <certfile>', 'SSL certificate to use, if any, for API requests')
.option('--default-target <host>', 'Default proxy target (proto://host[:port]')
.option('--redirect-port <redirect-port>', 'Redirect HTTP requests on this port to the server on HTTPS')
// passthrough http-proxy options
.option('--no-x-forward', "Don't add 'X-forward-' headers to proxied requests")
.option('--no-prepend-path', "Avoid prepending target paths to proxied requests")
@@ -75,6 +76,13 @@ if (args.apiSslKey || args.apiSslCert) {
options.default_target = args.defaultTarget;
options.host_routing = args.hostRouting;
options.auth_token = process.env.CONFIGPROXY_AUTH_TOKEN;
options.redirectPort = args.redirectPort;

// certs need to be provided for https redirection
if (!options.ssl && options.redirectPort) {
log.error("HTTPS redirection specified but certificates not provided.");
process.exit(2);
}

// passthrough for http-proxy options
if (args.insecure) options.secure = false;
@@ -89,7 +97,7 @@ if (!options.auth_token) {
var proxy = new ConfigurableProxy(options);

var listen = {};
listen.port = args.port || 8000;
listen.port = parseInt(args.port) || 8000;
listen.ip = args.ip;
listen.api_ip = args.apiIp || 'localhost';
listen.api_port = args.apiPort || listen.port + 1;
@@ -107,3 +115,18 @@ log.info("Proxy API at %s://%s:%s/api/routes",
(listen.api_ip || '*'),
listen.api_port);

// Redirect HTTP to HTTPS on the proxy's port
if (options.redirectPort && listen.port !== 80) {
var http = require('http');

http.createServer(function (req, res) {
var host = req.headers['host'].split(':')[0];

// Make sure that when we redirect, it's to the port the proxy is running on
if (listen.port !== 443) {
host = host + ':' + listen.port;
}
res.writeHead(301, { "Location": "https://" + host + req.url });
res.end();
}).listen(options.redirectPort);
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.3.0",
"version": "0.4.0",
"name": "configurable-http-proxy",
"description": "A configurable-on-the-fly HTTP Proxy",
"author": "Jupyter Developers",