Skip to content

Instantly share code, notes, and snippets.

@spiritualized
Last active May 24, 2023 23:44
Show Gist options
  • Save spiritualized/90581f03bc82cddc6cad3f75ebf70867 to your computer and use it in GitHub Desktop.
Save spiritualized/90581f03bc82cddc6cad3f75ebf70867 to your computer and use it in GitHub Desktop.
Nginx reverse proxy config for Planka with a URL prefix
# In your docker-compose.yaml, set
# - BASE_URL=https://myhost.com
# with no port and no URL prefix.
location ^~ /planka {
# Set proxy headers
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
# Define upstream address
set $upstream_app planka;
proxy_pass http://$upstream_app:1337; # NO TRAILING SLASH
# Remove /planka path to pass to the app
rewrite ^/planka/planka/planka/?(.*)$ /$1 break;
rewrite ^/planka/planka/?(.*)$ /$1 break;
rewrite ^/planka/?(.*)$ /$1 break;
# Sub filters to replace hardcoded paths
proxy_set_header Accept-Encoding "";
sub_filter_once off;
sub_filter_types *;
sub_filter 'href="/"' 'href="/$upstream_app"';
sub_filter '/planka/planka/static/' '/$upstream_app/static/';
sub_filter '/static/' '/$upstream_app/static/';
sub_filter '://$host' '://$host/planka';
sub_filter '/favicon' '/$upstream_app/favicon';
sub_filter '/manifest.json' '/$upstream_app/manifest.json';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment