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

Allow subdomains to work with no SERVER_NAME #905

Closed
yannk opened this issue Nov 4, 2013 · 5 comments
Closed

Allow subdomains to work with no SERVER_NAME #905

yannk opened this issue Nov 4, 2013 · 5 comments

Comments

@yannk
Copy link

yannk commented Nov 4, 2013

Would you be open to a patch allowing the use of subdomain routing with no SERVER_NAME pre-configured?

The motivation is to allow multiple domains to match a request, just like it does when SERVER_NAME is None, while still benefiting from the nice subdomain matcher. This is particularly useful in DEV to be able to develop on machine.local but also tunnel the instance to a vpn, and use things like xip.io (which all change the host).

The change would probably be mostly focused on create_url_adapter(). I imagine a configuration variable switching a different logic on for this function: it would look for subdomains and deduce the server_name which is the reverse of what's going on today.
The list of subdomains could come from the configuration I suppose, or better be deduced from the compilation of the routes.

  1. What do you think of this idea?
  2. If you are opposed to it, what alternative approach do you suggest instead?
  3. If you are not opposed to it, how do you think the implementation should look like?
@gregorynicholas
Copy link

👍 or at least one could provide detailed documentation on the functionality + configuration for this. it ended up being a very costly issue for me on my last major flask project due to the amount of time + debugging it took to get an app with subdomains working stably.

@mitsuhiko
Copy link
Contributor

How would that work?

@yannk
Copy link
Author

yannk commented Feb 9, 2014

IIRC (it's been a little while now), SERVER_NAME MUST be defined when subdomains are in use or it silently breaks. A patch would change that so that server_name is set from the request, but the list of configured subdomains would be taken into account so they are stripped from it.

I can work on a patch proposal if you like. The easiest would be to read the list of subdomains from the config, but it would be more elegant if it came from the routes, but I have to dig in the code to figure out how to extract that. What do you think?

@asciifaceman
Copy link

👍

This led to debating dumping blueprints with my partner

@davidism davidism added this to the 1.0 milestone Feb 6, 2018
@davidism davidism removed this from the 1.0 milestone Feb 23, 2018
@davidism
Copy link
Member

Subdomain routing requires setting the server name. It sounds like you want "wildcard" subdomains, where some routes don't care what subdomain they come in on. You can probably get this with some variable rules in the subdomain part, or by redirecting the subdomains to a canonical domain at the web server level. I don't think we should add anything to Flask at this time.

Note that #2635 allows setting SERVER_NAME without forcing subdomain matching, which may be what you were looking for.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants