Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix use of uploads directory on local server #208

Merged
merged 3 commits into from
Aug 26, 2020
Merged

Conversation

roborourke
Copy link
Contributor

After the change to the cloud module to ensure media paths matched the site's host name it broke local server's assumption that the uploads path was at s3-<project>.altis.dev.

This adds a 301 redirect on the nginx server to map to the correct URL on the S3 container.

@roborourke roborourke requested a review from joehoyle August 26, 2020 14:43
@@ -114,6 +114,9 @@ services:
- "traefik.port=8080"
- "traefik.protocol=https"
- "traefik.docker.network=proxy"
- "traefik.uploads.frontend.redirect.regex=^https?://(.*?).altis.dev/uploads/(.*)"
- "traefik.uploads.frontend.redirect.replacement=https://s3-${COMPOSE_PROJECT_NAME:-default}.altis.dev/uploads/$$2"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this use $$1 instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, I made that error first time round - there are 2 capturing brackets

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I mean instead of the environment variable, not instead of the path replacement

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's intentional. The S3 container URL will always be that

@@ -114,6 +114,10 @@ services:
- "traefik.port=8080"
- "traefik.protocol=https"
- "traefik.docker.network=proxy"
# Redirect any requests to /uploads to the S3 container frontend.
- "traefik.uploads.frontend.redirect.regex=^https?://(?:.*?).altis.dev/uploads/(.*)"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to check, this won't cause an infinite redirect right??

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did test it 😛 - the traefik rules apply first before the request gets to the container so s3-*.altis.dev requests are never handled by nginx.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WHen this says "redirect" does it mean HTTP redirect? If so, is this just used for legacy URLs? Just want to make sure we are not always issuing 301 redirects!

@roborourke roborourke merged commit b1adf25 into master Aug 26, 2020
@roborourke roborourke deleted the map-uploads branch August 26, 2020 15:10
@hm-backport
Copy link

hm-backport bot commented Aug 26, 2020

The backport to v4-branch failed:

Commits ["f529075a6590e6f6fc401ca61fab1a68cbdb4895","5f9d5fc55cd6d7ba92fc17c31b8c8b1c17c740f0","dee0167fe670d80d15d01c7265b7b3977cd72031"] could not be cherry-picked on top of v4-branch

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub.
git fetch
# Create new working tree.
git worktree add .worktrees/backport v4-branch
# Navigate to the new directory.
cd .worktrees/backport
# Cherry-pick all the commits of this pull request and resolve the likely conflicts.
git cherry-pick f529075a6590e6f6fc401ca61fab1a68cbdb4895 5f9d5fc55cd6d7ba92fc17c31b8c8b1c17c740f0 dee0167fe670d80d15d01c7265b7b3977cd72031
# Create a new branch with these backported commits.
git checkout -b backport-208-to-v4-branch
# Push it to GitHub.
git push --set-upstream origin backport-208-to-v4-branch
# Go back to the original working tree.
cd ../..
# Delete the working tree.
git worktree remove .worktrees/backport

Then, create a pull request where the base branch is v4-branch and the compare/head branch is backport-208-to-v4-branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants