Skip to content

Proxito: redirect to main project from subprojects #8187

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

Merged
merged 1 commit into from
May 19, 2021

Conversation

stsewd
Copy link
Member

@stsewd stsewd commented May 17, 2021

This introduces one more query for normal serving, except when a custom domain is used, there the queries are the same, I think this is fine.

Closes #7881
We can revert #7880
after releasing this.

Closes #7881
We can revert #7880
after releasing this.
self.assertIsNone(res)
self.assertEqual(getattr(request, 'canonicalize', None), 'subproject-main-domain')

# Using a custom domain in a subproject isn't supported (or shouldn't be!).
Copy link
Member Author

Choose a reason for hiding this comment

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

Added a test for this to check isn't failing since it could happen, but we can also move the subdomain check first. Think we have talked about checking this case in the domain creation form.

Copy link
Member

Choose a reason for hiding this comment

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

Yea, we shouldn't allow this.

@stsewd stsewd requested review from ericholscher and a team May 17, 2021 22:33
Copy link
Member

@ericholscher ericholscher left a comment

Choose a reason for hiding this comment

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

Looks good. I wonder if we should exclude the proxied API requests from this middleware or something, to reduce queries?

self.assertIsNone(res)
self.assertEqual(getattr(request, 'canonicalize', None), 'subproject-main-domain')

# Using a custom domain in a subproject isn't supported (or shouldn't be!).
Copy link
Member

Choose a reason for hiding this comment

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

Yea, we shouldn't allow this.

@@ -55,6 +55,57 @@ def test_single_version_subproject_root_url_no_slash(self):
r['Location'], 'https://project.dev.readthedocs.io/projects/subproject/',
)

def test_subproject_redirect(self):
r = self.client.get('/', HTTP_HOST='subproject.dev.readthedocs.io')
Copy link
Member

Choose a reason for hiding this comment

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

Does this break with the canonicalization around http -> https not doing the redirect?

Copy link
Member Author

Choose a reason for hiding this comment

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

do you mean http://suproject.rtd.io/foo? well, we do http -> https redirects from cloudflare/nginx, so it gets redirected to https://suproject.rtd.io/foo. We don't support custom domains on the domain of the subproject, but if a user sets one, we would redirect directly to the main domain, instead of passing for https first, yeah. And we don't allow redirects from subprojects (well we do, but they don't work #5889).

I may start adding some validation in our forms to avoid having to deal with that at all p:

@stsewd
Copy link
Member Author

stsewd commented May 19, 2021

I wonder if we should exclude the proxied API requests from this middleware or something, to reduce queries?

Good idea, I'll see if that can be done, proxied APIs usually pass the project and version as query args.

@stsewd stsewd merged commit 6239b5f into master May 19, 2021
@stsewd stsewd deleted the redirect-main-domain branch May 19, 2021 22:46
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.

Redirect subprojects to the main domain
2 participants