diff --git a/volumes/conf.d/etherpad.zinomedia.de.conf b/volumes/conf.d/etherpad.zinomedia.de.conf index 7c7fd29..dea66b3 100644 --- a/volumes/conf.d/etherpad.zinomedia.de.conf +++ b/volumes/conf.d/etherpad.zinomedia.de.conf @@ -8,69 +8,66 @@ server { listen [::]:443 ssl; server_name etherpad.zinomedia.de; + # TLS (yours) ssl_certificate /etc/letsencrypt/live/etherpad.zinomedia.de/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/etherpad.zinomedia.de/privkey.pem; - include "snippets/ssl-optimizations.conf"; + # Optional basic auth auth_basic "Protected"; auth_basic_user_file /usr/share/nginx/html/etherpad.zinomedia.de/.htpasswd; - # Docker DNS + # Docker DNS (because proxying to "etherpad") resolver 127.0.0.11 valid=30s ipv6=off; - # 1) Pass-through (original, no /p/ prefix) - location ~ ^/(locales/|locales\.json|admin/|static/|pluginfw/|javascripts/|socket\.io/|ep/|minified/|api/|ro/|error/|jserror|redirect|favicon\.ico|robots\.txt|indexBootstrap-.*\.js)$ { + # ---- Allow normal files to pass through (exactly as in wiki) ---- + location ~ ^/(locales/|locales\.json|admin/|static/|pluginfw/|javascripts/|socket\.io/|ep/|minified/|api/|ro/|error/|jserror/|favicon\.ico|robots\.txt|.*\.js)$ { set $upstream "http://etherpad:9001"; proxy_pass $upstream; proxy_buffering off; - proxy_http_version 1.1; proxy_set_header Host $host; + proxy_pass_header Server; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $connection_upgrade; 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-Host $host; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection $connection_upgrade; } - # 2) Strip /p/ prefix from those same paths (INTERNAL rewrite, no 301) - location ~ ^/p/(locales/|locales\.json|admin/|static/|pluginfw/|javascripts/|socket\.io/|ep/|minified/|api/|ro/|error/|jserror|redirect|favicon\.ico|robots\.txt|indexBootstrap-.*\.js) { - rewrite ^/p/(.*)$ /$1 last; - } - - # 3) Root -> Etherpad UI - location = / { - set $upstream "http://etherpad:9001"; - proxy_pass $upstream; - proxy_buffering off; - proxy_http_version 1.1; - 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-Host $host; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection $connection_upgrade; - } - - # 4) All pad URLs under /p/ — just proxy (NO ^~ so regex above can win) + # ---- Redirect /p/* to friendly version / (exactly as in wiki) ---- location /p/ { + rewrite ^/p/(.*) /$1 redirect; + } + + # ---- Home page ---- + location ~ ^/$ { set $upstream "http://etherpad:9001"; proxy_pass $upstream; proxy_buffering off; - proxy_http_version 1.1; proxy_set_header Host $host; + proxy_pass_header Server; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $connection_upgrade; 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-Host $host; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection $connection_upgrade; } - # 5) Friendly URLs for anything else: /foo -> /p/foo (single 301) + # ---- Handle pad URLs: keep browser at /, map upstream redirects / -> /p/ ---- location / { - return 301 /p$uri$is_args$args; + proxy_redirect / /p/; + set $upstream "http://etherpad:9001"; + proxy_pass $upstream; + proxy_buffering off; + proxy_set_header Host $host; + proxy_pass_header Server; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $connection_upgrade; + 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; } }