Files
docker-docs/_deploy/nginx/default.conf
Sebastiaan van Stijn 628b77dc82 NGINX config: add redirect rules for obsolete archive pages
This adds redirect rules to redirect URLs for archives that are no longer hosted
to the current documentation.

Some test scenarios below to verify:

Current docs
--------------------------------------------------------------------------------

- http://localhost:4000/engine/reference/commandline/create
    - redirects to http://localhost:4000/engine/reference/commandline/create/ (with trailing slash)
- http://localhost:4000/engine/reference/commandline/create/
- http://localhost:4000/engine/reference/commandline/create/index.html

Archived docs for current archives (e.g. v18.09):
--------------------------------------------------------------------------------

- http://localhost:4000/v18.09/engine/reference/commandline/create
  - ideally this should redirect to http://localhost:4000/v18.09/engine/reference/commandline/create/ (with trailing slash)
- http://localhost:4000/v18.09/engine/reference/commandline/create/
- http://localhost:4000/v18.09/engine/reference/commandline/create/index.html

Non-existing pages
--------------------------------------------------------------------------------

These should produce a 404 (not found)

- http://localhost:4000/no/such/page/
- http://localhost:4000/v18.09/no/such/page/
    - redirects to http://localhost:4000/no/such/page/

URLs for archived versions that are not, or no longer, published
--------------------------------------------------------------------------------
These are not found, because we don't (or no longer) publish these archive versions.
Because they start with `/vXX.XX/`, we redirect them to the same location in the
current docs. Note that the location redirected to may not (or no longer) exist,
and as such could result in another 301 redirect, or a ultimately a 404 ("not found").

Given that these should not re-appear, these redirects use a 301 (permanent). There
is one corner case; URLs for _future_ releases (e.g. `/v20.03/`) will _also_ produce
a 301, which could be cached by browsers / proxies, and effectively "block" the
URL for future use. I don't think this is very problematic, or at least not
something we should care about.

- http://localhost:4000/v17.99/engine/reference/commandline/run
    - redirects to http://localhost:4000/engine/reference/commandline/run/ in the current docs
- http://localhost:4000/v17.99/engine/reference/commandline/run/
    - redirects to http://localhost:4000/engine/reference/commandline/run/ in the current docs
- http://localhost:4000/v17.99/engine/reference/commandline/run/index.html
    - redirects to http://localhost:4000/engine/reference/commandline/run/index.html  in the current docs

Non existing pages in archive paths
--------------------------------------------------------------------------------

- http://localhost:4000/v17.03/no/such/page/
    - redirects to http://localhost:4000/no/such/page/ in the current docs
    - which shows a 404 not found page

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-02-28 15:10:24 +01:00

27 lines
976 B
Plaintext

server {
# Use relative redirects to account for situations where a front-end proxy is
# used and the container does not know the public domain and port
absolute_redirect off;
listen 4000;
error_page 403 404 /404.html;
root /usr/share/nginx/html;
index index.html;
# Enable aio for better performance (see https://www.nginx.com/blog/thread-pools-boost-performance-9x/)
aio threads;
location ~ ^/v([\d\.]+)/(.*)$ {
# Archive URLs: first try if the given file is still hosted, otherwise
# redirect to the same URL in the current version of the docs.
try_files $uri $uri/ @redirect_current;
}
location @redirect_current {
# Do a 301 (moved permanently) redirect of archive pages we didn't find
# to the same location in the current docs. Note that the location redirected
# to may not (or no longer) exist, and as such could result in another 301
# redirect, or a 404.
rewrite ^/v([\d\.]+)/(.*)$ /$2 permanent;
}
}