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

Dynamic Subdomain - Routes Configuration #48

Closed
ghost opened this issue May 25, 2017 · 11 comments
Closed

Dynamic Subdomain - Routes Configuration #48

ghost opened this issue May 25, 2017 · 11 comments

Comments

@ghost
Copy link

ghost commented May 25, 2017

localhost {
host = "localhost,127.0.0.1,a.com" ?
}
admin_localhost {
host = "admin.localhost"
}

How can I support multiple domain names?

Thank you!

@ghost
Copy link
Author

ghost commented May 25, 2017

An example is if you wanted users to have their own subdomains like GitHub Pages: {username}.github.io

@jeevatkm
Copy link
Member

Docs: Configuring subdomain

Example: It's good to add this info in the docs :)

localhost {
    host = "localhost"
}

admin_localhost {
    host = "admin.localhost"
    subdomain = true
}

When you go for non-dev env, production, etc. Then you override these values in environment profile, refer to docs.

@ghost
Copy link
Author

ghost commented May 25, 2017

Must use nginx?

@ghost
Copy link
Author

ghost commented May 25, 2017

Dynamic binding domains,Users resolve their domain names。

@jeevatkm
Copy link
Member

No, I'm using it for my purpose. Since on 443 port I'm running multiple services along with aah application. That is why.

Please Note: proxy server or web server is not required in your scenario.

Important things is router have to know hostname and port based on your targeted environment.

Let's go by example:

  1. You're doing development on your machine, route config is-
localhost {
    host = "localhost"
    # see we are not mentioning port here, because router takes default as 8080
}

admin_localhost {
    host = "admin.localhost"
    # see we are not mentioning port here, because router takes default as 8080

    subdomain = true
}

You access your aah application during development like http://localhost:8080 and http://admin.localhost

  1. Now, you want to deploy aah application on server with port 80, which is applicable only to prod env profile.
localhost {
    host = "sample.com"
    port = "80"
}

admin_localhost {
    host = "admin.sample.com"
    port = "80"

    subdomain = true
}

That's it. Your application is ready to access on http://sample.com and http://admin.sample.com

@ghost
Copy link
Author

ghost commented May 25, 2017

I understand what you mean。
I now need to allow users to bind their own domain name。

Similar to pan analysis。

localhost {
host = "*"
port = "80"
}
http://sample.com / http://abc.com / http://abcd.com

admin_localhost {
host = "admin.sample.com"
port = "80"
}
http://admin.sample.com

@ghost
Copy link
Author

ghost commented May 25, 2017

Sorry, my English is not very good

@jeevatkm
Copy link
Member

jeevatkm commented May 25, 2017

Dynamic binding domains,Users resolve their domain names。

Currently aah framework support static binding of sub-domains.


You mean adding feature of *.sample.com so that jeeva.sample.com, lesou.sample.com??

Call the specified key name when no matching route is found,Can this be set up?

Yes, you register Route not found in the routes.conf But not for host/domain names is not found. Docs reference for not found

However, there is a workaround you can do achieve your desire result.

Workaround is-

  • Define route configuration as dynamic.sample.com and define all your routes.
  • Register OnRequest server event docs reference
    • This is published for every request before route is evaluated
  • Use SetURL() method to translate
    • lesou.sample.com to dynamic.sample.com and
    • lesou store this value in the ViewArgs using ctx.AddViewArgs
    • Then you access the subdomain name in the controller

Also can you please create an feature for dynamic binding?

@jeevatkm
Copy link
Member

Yes, you can do this. Using above workaround which I mentioned

localhost {
host = "*"
port = "80"
}

admin_localhost {
host = "admin.sample.com"
port = "80"
}

@ghost
Copy link
Author

ghost commented May 25, 2017

Thank you, resolved

@ghost ghost closed this as completed May 25, 2017
@jeevatkm
Copy link
Member

You can also use Query Parameter like-

ctx.Req.Params.Query.Set("subdomainName", subdomainName)

in the controller, you can access.

c.Req.QueryValue("subdomainName")

Thank you, Please create a feature request? I will add support for wildcard subdomain support out-of-the-box.

@jeevatkm jeevatkm changed the title Routes Configuration Dynamic Subdomain - Routes Configuration May 25, 2017
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant