Skip to content

Instantly share code, notes, and snippets.

@fabriciojf
Forked from spiritualized/uptime-kuma.conf
Created October 23, 2023 16:50
Show Gist options
  • Save fabriciojf/0c523cf1d703933b4320a07302d8c64a to your computer and use it in GitHub Desktop.
Save fabriciojf/0c523cf1d703933b4320a07302d8c64a to your computer and use it in GitHub Desktop.
Uptime Kuma reverse proxy nginx config for a URL prefix
# nginx configuration snippet for running Uptime Kuma on a URL prefix
# set up for yourdomain.com/kuma, with traffic forwarded to a docker
# container with the hostname 'uptime-kuma'
# Use docker's DNS
resolver 127.0.0.11;
# uptime kuma
location /uptime {
# Define upstream address
set $upstream_app uptime-kuma;
set $url_prefix uptime;
proxy_pass http://$upstream_app:3001;
# Set proxy headers
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Protocol $scheme;
proxy_set_header X-Forwarded-Host $http_host;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_buffering off;
# Redirect location headers
proxy_redirect ^ /$url_prefix;
proxy_redirect /dashboard /$url_prefix/dashboard;
# Remove URL prefix to pass to the app
rewrite ^/uptime/?(.*)$ /$1 break;
# Sub filters to replace hardcoded paths
proxy_set_header Accept-Encoding "";
sub_filter_once off;
sub_filter_types *;
sub_filter '/assets/' '/$url_prefix/assets/';
sub_filter '"assets/' '"$url_prefix/assets/';
sub_filter '/dashboard' '/$url_prefix/dashboard';
sub_filter '"/socket.io"' '"/$url_prefix/socket.io"';
sub_filter '"/icon.svg"' '"/$url_prefix/icon.svg"';
sub_filter '"/favicon.ico"' '"/$url_prefix/favicon.ico"';
sub_filter '"/manifest.json"' '"/$url_prefix/manifest.json"';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment