diff --git a/chart/config/proxy/lib.error-generic.conf b/chart/config/proxy/lib.error-generic.conf deleted file mode 100644 index d64fb90dbf0ce9..00000000000000 --- a/chart/config/proxy/lib.error-generic.conf +++ /dev/null @@ -1,10 +0,0 @@ -# Preconditions: -# An @error_404 error handler in this or any upper context -# An @error_generic error handler in this or any upper context - -error_page 404 @error_404; - -# https://en.wikipedia.org/wiki/List_of_HTTP_status_codes -# Unfortunately, nginx requires us to list all error codes explicitly... -# I'm not totally sure which of those are needed and which are more esoteric, so: more is better -error_page 400 401 403 405 406 407 408 409 410 411 412 413 414 415 416 417 426 428 429 431 500 501 502 503 504 505 506 510 511 =200 @error_generic; diff --git a/chart/config/proxy/lib.locations.conf b/chart/config/proxy/lib.locations.conf index 559d8934a6e13b..e2cd618a3b3666 100644 --- a/chart/config/proxy/lib.locations.conf +++ b/chart/config/proxy/lib.locations.conf @@ -1,7 +1,5 @@ {{- $this := dict "root" . "gp" $.Values }} include lib.resolver.conf; -include lib.error-generic.conf; - ####################################################### # Reverse-proxy for server service @@ -23,14 +21,6 @@ location / { include lib.cors-headers.conf; proxy_pass http://dashboard$request_uri; - - # # # Page Not Found - # # Let's redirect the browser agent to the web app, if no resources are found in the locations specified here. - # # - # # This is derived from the issue https://github.com/gitpod-io/gitpod/issues/2659, which - # # was appearently caused by Twitter's link shortening. So, if the leading www is missing - # # in the URL by accident, we will redirect to the web on 404 – Not Found. - # error_page 404 @error_404_dashboard; } # location @error_404_dashboard { @@ -194,4 +184,4 @@ location @error_404 { location @error_generic { # Something really bad happened: One of the requested resources is not there, at all. Redirect to the generic error page return 302 {{ template "gitpod.scheme" $this }}://{{.Values.hostname}}/sorry/#Error%20$upstream_status; -} \ No newline at end of file +} diff --git a/components/dashboard/conf/Caddyfile b/components/dashboard/conf/Caddyfile index 680b3d7ead02e2..2b0bfe9c32b01c 100644 --- a/components/dashboard/conf/Caddyfile +++ b/components/dashboard/conf/Caddyfile @@ -13,35 +13,63 @@ } } -:80 { - @static { +(static) { + @static_path { + path /static/* + } + + @static_asset { + file path /static/* } - @notstatic { + # static assets configure cache headers and do not check for changes + header @static_asset { + Cache-Control "public, max-age=31536000" + # remove Last-Modified header + -Last-Modified + } +} + +(notstatic) { + @not_static_path { + not path /static/* + } + + @not_static_assets { not path /static/* } + header @not_static_assets { + Cache-Control "no-cache, no-transform, must-revalidate" + } +} + +:80 { import compression import discard_log + import static + import notstatic redir /.well-known/security.txt https://www.gitpod.io/.well-known/security.txt permanent redir /environment-variables /settings/ permanent - handle @static { - header Cache-Control "public, max-age=31536000" - } - - handle @notstatic { - header Cache-Control "no-cache, no-transform, must-revalidate" - } - header -Server - header -Last-Modified root * /www file_server - try_files {path} {path}/ /index.html + + handle @static_path { + try_files {path} + } + + handle @not_static_path { + try_files {path} {path}/ /index.html + } + + handle { + respond "404 - Not Found" 404 + } } # health-check