mirror of
https://github.com/sablierapp/sablier.git
synced 2025-12-21 13:23:03 +01:00
Documentation is now published on the `gh-pages` branch. The branch will have a folder `docs` containing the following structure: - `./docs` the copy from the `main` docs, but only used for the `index.html` page to do the multi-version routing. - `./docs/main` the copy from the `main` branch docs folder - `./docs/beta` the copy from the `beta` branch docs folder Closes #332
3.1 KiB
3.1 KiB
Nginx Sablier Plugin
The Nginx Sablier Plugin is a javascript file that runs through the NJS Module.
Provider compatibility grid
| Provider | Dynamic | Blocking |
|---|---|---|
| Docker | ✅ | ✅ |
| Docker Swarm | ✅ | ✅ |
| Kubernetes | ❌ | ❌ |
Install the plugin to NGINX
- Load the
ngx_http_js_module.soin the main nginx config file/etc/nginx/nginx.confload_module modules/ngx_http_js_module.so; - Copy/volume the
sablier.jsfile to/etc/nginx/conf.d/sablier.js
Configure the plugin
Use this sample for your APIs
js_import conf.d/sablier.js;
resolver 127.0.0.11 valid=10s ipv6=off;
server {
listen 80;
subrequest_output_buffer_size 32k;
# The internal location to reach sablier API
set $sablierUrl /sablier;
# Shared variable for default session duration
set $sablierSessionDuration 1m;
# internal location for sablier middleware
# here, the sablier API is a container named "sablier" inside the same network as nginx
location /sablier/ {
internal;
proxy_method GET;
proxy_pass http://sablier:10000/;
}
# A named location that can be used by the sablier middleware to redirect
location @whoami {
# Use variable in order to refresh DNS cache
set $whoami_server whoami;
proxy_pass http://$whoami_server:80;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
# The actual location to match your API
# Will answer by a waiting page or redirect to your app if
# it is already up
location /dynamic/whoami {
set $sablierDynamicShowDetails true;
set $sablierDynamicRefreshFrequency 5s;
set $sablierNginxInternalRedirect @whoami;
set $sablierGroup my-group;
set $sablierDynamicName "Dynamic Whoami";
set $sablierDynamicTheme hacker-terminal;
js_content sablier.call;
}
}
Available variables
You can configure the middleware behavior with the following variables:
General Configuration
set $sablierUrlThe internal routing to reach Sablier APIset $sablierGroupGroup name to use to filter by label, ignored if sablierNames is setset $sablierSessionDurationThe session duration after which containers/services/deployments instances are shutdownset $sablierNginxInternalRedirectThe internal location for the service to redirect e.g. @nginx
Dynamic Configuration
if any of these variables is set, then all Blocking Configuration is ignored
set $sablierDynamicNameset $sablierDynamicShowDetailsSet to true or false to show details specifcally for this middleware, unset to use Sablier server defaultsset $sablierDynamicThemeThe theme to useset $sablierDynamicRefreshFrequencyThe loading page refresh frequency
Blocking Configuration
set $sablierBlockingTimeoutwaits until services are up and running but will not wait more thantimeout