Skip to content

Instantly share code, notes, and snippets.

@mkornatz
Last active February 2, 2022 16:57
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mkornatz/24e573923d6340b1aca8487225eb65e2 to your computer and use it in GitHub Desktop.
Save mkornatz/24e573923d6340b1aca8487225eb65e2 to your computer and use it in GitHub Desktop.
DataHub nginx proxy configuration (supports websockets)
# This configuration can be used to create a reverse proxy for use with Figment's DataHub service
#
# This file can be included by placing it into /etc/nginx/sites-enabled/ (Debian based distros)
# or /etc/nginx/conf.d/ (Red Hat based distros)
server {
# The proxy will listen on port 80 (SSL is not enabled)
listen 80;
# Replace EXAMPLE with the DataHub service name
set $datahub_service_url https://EXAMPLE.datahub.figment.io
# Replace YOUR_DATAHUB_API_KEY with your DataHub api key for this service
set $auth_token YOUR_DATAHUB_API_KEY;
location / {
try_files /nonexistent-used-for-try-testing @$http_upgrade;
}
location @websocket {
proxy_pass $datahub_service_url$request_uri;
proxy_http_version 1.1;
proxy_set_header Host $proxy_host;
# websocket requirements
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Authorization "$auth_token";
proxy_redirect https://$proxy_host http://$server_name:$server_port;
proxy_redirect https:// http://;
}
location @ {
proxy_pass $datahub_service_url$request_uri;
proxy_http_version 1.1;
proxy_set_header Host $proxy_host;
proxy_set_header Connection "";
proxy_set_header Authorization "$auth_token";
proxy_redirect https://$proxy_host http://$server_name:$server_port;
proxy_redirect https:// http://;
}
}
@nkrsic
Copy link

nkrsic commented Jan 22, 2022

Thank you for this recipe. For future users, this is useful for Tendermint-based clients which want to call RPC endpoints, but handle the URL query formation with their own internal logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment