-
Notifications
You must be signed in to change notification settings - Fork 132
[WIP] Add the Ability to use Redis for Storage #85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
a755576
0ac02d9
3c28591
63f2a77
f251f45
3beaf58
f95f120
f2adccf
94bb611
f143f16
b385007
efc7679
23b66d3
07bfe07
d1c3a1a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,7 @@ using the npm package manager: | |
npm install -g configurable-http-proxy | ||
|
||
To install from the source code found in this GitHub repo: | ||
|
||
git clone https://github.com/jupyterhub/configurable-http-proxy.git | ||
cd configurable-http-proxy | ||
# Use -g for global install | ||
|
@@ -54,7 +54,7 @@ The configurable proxy runs two HTTP(S) servers: | |
|
||
### Setting a default target | ||
|
||
When you start the proxy from the command line, you can set a | ||
When you start the proxy from the command line, you can set a | ||
default target (`--default-target` option) to be used when no | ||
matching route is found in the proxy table: | ||
|
||
|
@@ -71,7 +71,8 @@ matching route is found in the proxy table: | |
-V, --version output the version number | ||
--ip <ip-address> Public-facing IP of the proxy | ||
--port <n> (defaults to 8000) Public-facing port of the proxy | ||
|
||
--storage-command <script> The optional external executable to use for persistence | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm wondering if we can come up with a more specific name here than One suggestion: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Scratch my earlier suggestion of |
||
|
||
--ssl-key <keyfile> SSL key to use, if any | ||
--ssl-cert <certfile> SSL certificate to use, if any | ||
--ssl-ca <ca-file> SSL certificate authority, if any | ||
|
@@ -81,15 +82,15 @@ matching route is found in the proxy table: | |
--ssl-ciphers <ciphers> `:`-separated ssl cipher list. Default excludes RC4 | ||
--ssl-allow-rc4 Allow RC4 cipher for SSL (disabled by default) | ||
--ssl-dhparam <dhparam-file> SSL Diffie-Helman Parameters pem file, if any | ||
|
||
--api-ip <ip> Inward-facing IP for API requests | ||
--api-port <n> Inward-facing port for API requests (defaults to --port=value+1) | ||
--api-ssl-key <keyfile> SSL key to use, if any, for API requests | ||
--api-ssl-cert <certfile> SSL certificate to use, if any, for API requests | ||
--api-ssl-ca <ca-file> SSL certificate authority, if any, for API requests | ||
--api-ssl-request-cert Request SSL certs to authenticate clients for API requests | ||
--api-ssl-reject-unauthorized Reject unauthorized SSL connections (only meaningful if --api-ssl-request-cert is given) | ||
|
||
--default-target <host> Default proxy target (proto://host[:port]) | ||
--error-target <host> Alternate server for handling proxy errors (proto://host[:port]) | ||
--error-path <path> Alternate server for handling proxy errors (proto://host[:port]) | ||
|
@@ -109,7 +110,7 @@ matching route is found in the proxy table: | |
|
||
## Using the REST API | ||
|
||
The configurable-http-proxy API is documented and available at the | ||
The configurable-http-proxy API is documented and available at the | ||
interactive swagger site, [petstore](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyterhub/configurable-http-proxy/master/doc/rest-api.yml#/default) | ||
or as a [swagger specification file in this repo](https://github.com/jupyterhub/configurable-http-proxy/blob/master/doc/rest-api.yml). | ||
|
||
|
@@ -202,7 +203,7 @@ with their status code: | |
- 404: a client has requested a URL for which there is no routing target. | ||
This can be prevented if a `default target` is specified when starting | ||
the configurable-http-proxy. | ||
|
||
- 503: a route exists, but the upstream server isn't responding. | ||
This is more common, and can be due to any number of reasons, | ||
including the target service having died or not finished starting. | ||
|
@@ -211,10 +212,10 @@ with their status code: | |
|
||
If you specify an error path `--error-path /usr/share/chp-errors` when | ||
starting the CHP: | ||
|
||
configurable-http-proxy --error-path /usr/share/chp-errors | ||
then when a proxy error occurs, CHP will look in | ||
|
||
then when a proxy error occurs, CHP will look in | ||
`/usr/share/chp-errors/<CODE>.html` (where CODE is the status code number) | ||
for an html page to serve, e.g. `404.html` or `503.html`. | ||
|
||
|
@@ -225,7 +226,7 @@ If you specify an error path, make sure you also create `error.html`. | |
|
||
When starting the CHP, you can pass a command line option for `--error-target`. | ||
If you specify `--error-target http://localhost:1234`, | ||
then when the proxy encounters an error, it will make a GET request to | ||
then when the proxy encounters an error, it will make a GET request to | ||
this server, with URL `/CODE`, and the URL of the failing request | ||
escaped in a URL parameter, e.g.: | ||
|
||
|
@@ -247,3 +248,26 @@ first part of the URL path, e.g.: | |
"/otherdomain.biz": "http://10.0.1.4:5555", | ||
} | ||
``` | ||
|
||
## Using External Storage | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: I'll have more detail after Min and Kyle's reviews.
|
||
|
||
By default CHP uses memory in the local process for storing the route table. If you'd prefer to use an external storage | ||
mechanism, like redis, memcached, mysql, etc. You can specify an executable to be used instead, by passing the path to | ||
your script in the `--storage-command` option. | ||
|
||
To do this, you'll need to ensure that the script is both accessible on the path and executable. The script should | ||
support the following API, where `<path>` is the incoming request path and `<base64_json>` is a base64 encoded JSON | ||
object. | ||
|
||
``` | ||
$ /path/to/script get <path> | ||
$ /path/to/script get_all | ||
$ /path/to/script add <path> <base64_json> | ||
$ /path/to/script update <path> <base64_json> | ||
$ /path/to/script remove <path> | ||
$ /path/to/script exists <path> | ||
``` | ||
|
||
For an example, check out [the script] we use for testing this functionality. | ||
|
||
[the script]: https://github.com/jupyterhub/configurable-http-proxy/blob/master/test/support/external_store |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I swear it was vim not me! 😄