Allow redirects #9
Labels
No milestone
No project
No assignees
1 participant
Notifications
Total time spent: 2 hours 40 minutes
Due date
ric
2 hours 40 minutes
No due date set.
Dependencies
No dependencies set.
Reference
SquareCows/pages-server#9
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Implement a method to allow redirects
In order to support redirects we will introduce a system for custom domains only as this will rely on adding settings to the traefik config in Redis. We should add the ability to read a .redirects file from the root of the repository and only process it IF a custom domain is present in .pages. This file will be read in by the plugin and automatically add a rule to the custom domain mapping in Redis which lets traefik handle redirects automatically without passing to the plugin. This is handled by creating custom middleware: https://doc.traefik.io/traefik/reference/routing-configuration/http/middlewares/redirectregex/
the .redirect file should be in the format:
URL:REDIRECT_URL
URL = the object to detect and redirect
REDIRECT_URL = the new location
examples of this would be:
moo:bar
index.html:myapp/
There may be multiple redirects in a file, so the plugin should loop over the file and process every line. In the main middleware.yml file there should be a new configuration value of maxRedirects defaulting to 25. this limits how many lines the plugin will read from the file to prevent resource exhaustion.
In order to load the redirects into the system the user needs to visit https://Their_custom_domain.com/LOAD_REDIRECTS this will trigger the functions to get and parse the file and add the middleware redirectregex to the domain config in traefik. If the user visits that URL and the repository does not have a .redirects file or there is no custom domain configured in .pages the plugin should return an error page and point to the bovine documentation for help in configuring