Allow redirects #9

Closed
opened 2025-12-03 09:38:01 +00:00 by ric · 1 comment
Owner

Implement a method to allow redirects

Implement a method to allow redirects
ric self-assigned this 2025-12-03 09:38:01 +00:00
ric added this to the Roadmap project 2025-12-03 09:38:01 +00:00
ric added this to the 0.1.x release milestone 2025-12-03 23:37:30 +00:00
Author
Owner

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

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
ric closed this issue 2025-12-04 19:33:42 +00:00
ric stopped working 2025-12-04 19:33:42 +00:00
2 hours 40 minutes
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Total time spent: 2 hours 40 minutes
ric
2 hours 40 minutes
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
SquareCows/pages-server#9
No description provided.