forked from sokil/statsd-http-proxy
-
Notifications
You must be signed in to change notification settings - Fork 6
Added https support #9
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,3 +18,6 @@ src | |
|
|
||
| # Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736 | ||
| .glide/ | ||
|
|
||
| # keys | ||
| *.pem | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,7 +58,7 @@ Basic implementation of proxy client may be found at https://github.com/GoMetric | |
|
|
||
| ## Usage | ||
|
|
||
| Run server: | ||
| * Run server (HTTP): | ||
|
|
||
| ```bash | ||
| statsd-http-proxy \ | ||
|
|
@@ -71,6 +71,21 @@ statsd-http-proxy \ | |
| --metric-prefix=prefix.subprefix | ||
| ``` | ||
|
|
||
| * Run server (HTTPS): | ||
|
|
||
| ```bash | ||
| statsd-http-proxy \ | ||
| --verbose \ | ||
| --http-host=127.0.0.1 \ | ||
| --http-port=433 \ | ||
| --tls-cert=cert.pem \ | ||
| --tls-key=key.pem \ | ||
| --statsd-host=127.0.0.1 \ | ||
| --statsd-port=8125 \ | ||
| --jwt-secret=somesecret \ | ||
| --metric-prefix=prefix.subprefix | ||
| ``` | ||
|
|
||
| Print server version and exit: | ||
|
|
||
| ```bash | ||
|
|
@@ -79,19 +94,23 @@ statsd-http-proxy --version | |
|
|
||
| Command line arguments: | ||
|
|
||
| | Parameter | Description | Default value | | ||
| |-----------------|--------------------------------------|--------------------------------------------------------------------------------| | ||
| | verbose | Print debug info to stderr | Optional. Default false | | ||
| | http-host | Host of HTTP server | Optional. Default 127.0.0.1. To accept connections on any interface, set to "" | | ||
| | http-port | Port of HTTP server | Optional. Default 80 | | ||
| | statsd-host | Host of StatsD instance | Optional. Default 127.0.0.1 | | ||
| | statsd-port | Port of StatsD instance | Optional. Default 8125 | | ||
| | jwt-secret | JWT token secret | Optional. If not set, server accepts all connections | | ||
| | metric-prefix | Prefix, added to any metric name | Optional. If not set, do not add prefix | | ||
| | version | Print version of server and exit | Optional | | ||
| | Parameter | Description | Default value | | ||
| |-----------------|--------------------------------------|-----------------------------------------------------------------------------------| | ||
| | verbose | Print debug info to stderr | Optional. Default false | | ||
| | http-host | Host of HTTP server | Optional. Default 127.0.0.1. To accept connections on any interface, set to "" | | ||
| | http-port | Port of HTTP server | Optional. Default 80 | | ||
| | tls-cert | TLS certificate for the HTTPS | Optional. Default "" to use HTTP. If both tls-cert and tls-key set, HTTPS is used | | ||
| | tls-key | TLS private key for the HTTPS | Optional. Default "" to use HTTP. If both tls-cert and tls-key set, HTTPS is used | | ||
| | statsd-host | Host of StatsD instance | Optional. Default 127.0.0.1 | | ||
| | statsd-port | Port of StatsD instance | Optional. Default 8125 | | ||
| | jwt-secret | JWT token secret | Optional. If not set, server accepts all connections | | ||
| | metric-prefix | Prefix, added to any metric name | Optional. If not set, do not add prefix | | ||
| | version | Print version of server and exit | Optional | | ||
|
|
||
| Sample code to send metric in browser with JWT token in header: | ||
|
|
||
| * HTTP: | ||
|
|
||
| ```javascript | ||
| $.ajax({ | ||
| url: 'http://127.0.0.1:8080/count/some.key.name', | ||
|
|
@@ -105,6 +124,21 @@ $.ajax({ | |
| }); | ||
| ``` | ||
|
|
||
| * HTTPS (if self-signed certificate is used it has to be accepted!): | ||
|
|
||
| ```javascript | ||
| $.ajax({ | ||
| url: 'https://127.0.0.1:433/count/some.key.name', | ||
|
Member
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. this samples differ only by url. Everyone know what it is https))
Author
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. removed, merged into the existing index.html |
||
| method: 'POST', | ||
| headers: { | ||
| 'X-JWT-Token' => 'some-jwt-token' | ||
| }, | ||
| data: { | ||
| value: 100500 | ||
| } | ||
| }); | ||
| ``` | ||
|
|
||
| ## Authentication | ||
|
|
||
| Authentication is optional. It based on passing JWT token to server, encrypted with secret, specified in `jwt-secret` | ||
|
|
@@ -178,7 +212,7 @@ value=1 | |
|
|
||
| | Parameter | Description | Default value | | ||
| |------------|--------------------------------------|------------------------------------| | ||
| | value | Integer value | Optional. Default 1 | | ||
| | value | Integer value | Optional. Default 1 | | ||
|
|
||
| ## Response | ||
|
|
||
|
|
@@ -188,7 +222,7 @@ Other HTTP status codes: | |
|
|
||
| | CODE | Description | | ||
| |------------------|-----------------------------------------| | ||
| | 400 Bad Request | Invalid parameters specified | | ||
| | 400 Bad Request | Invalid parameters specified | | ||
| | 401 Unauthorized | Token not sent | | ||
| | 403 Forbidden | Token invalid/expired | | ||
| | 404 Not found | Invalid url requested | | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| #!/bin/sh | ||
|
|
||
| # This server start listening connections by HTTPS and pass it to StatsD by UDP | ||
|
|
||
| if [ ! -f "key.pem" -o ! -f "cert.pem" ]; then | ||
| echo "Https credentials do not exist. Generating new self-signed certificate and key with a default subject" | ||
|
|
||
| openssl req -x509 -nodes -days 358000 -newkey rsa:2048 -keyout key.pem -out cert.pem -subj "/C=PL/ST=test/L=test/O=test/OU=test/CN=test" | ||
| fi | ||
|
|
||
| CURRENT_DIR=$(dirname $(readlink -f $0)) | ||
|
|
||
| $CURRENT_DIR/../bin/statsd-http-proxy \ | ||
| --verbose \ | ||
| --http-host=127.0.0.1 \ | ||
| --http-port=433 \ | ||
| --tls-cert=cert.pem \ | ||
| --tls-key=key.pem \ | ||
| --statsd-host=127.0.0.1 \ | ||
| --statsd-port=8125 \ | ||
| --jwt-secret=somesecret \ | ||
| --metric-prefix=prefix.subprefix |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
pem ignored in all project or just in demo dir?
Uh oh!
There was an error while loading. Please reload this page.
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 would generally exlude pem files from the whole project. They should never be checked in. For demo it will be generated on the fly.