我现在有一个支持子域的Rails应用。用户可以使用abc.myapp.com
之类的URL。使用[加密*.myapp.com
的通配符证书]提供SSL。
现在,需要根据用户的偏好将应用程序映射到另一个域。就像,用户必须能够使用“让我们加密”将abc.myapp.com
映射到hello.otherapp.com
。
以下是我所谈论的参考:https://support.freshdesk.com/support/solutions/articles/227540-can-i-use-a-vanity-url-custom-domain-for-my-customer-portal-https://help.canny.io/en/articles/1355038-setting-up-your-custom-domain
我的堆栈是:1. Ruby on Rails2. Nginx3.让我们加密
您通常有3个步骤:
*.domain.com
server_name *.domain.com;
文档:http://nginx.org/en/docs/http/server_names.html您的Rails应用程序必须在蓝图中像application_controller.rb
那样放置,其代码类似
User.find_by (subdomain: request.subdomain)
并且要读取路径/路线,您必须使用constraints
。
文档:https://guides.rubyonrails.org/routing.html#request-based-constraints