【问题标题】:On the fly custom domains using Rails + Nginx + Let’s Encrypt使用 Rails + Nginx + Let's Encrypt 的动态自定义域
【发布时间】:2020-03-21 17:03:49
【问题描述】:

我现在有一个支持子域的 Rails 应用程序。用户可以拥有像 abc.myapp.com 这样的 URL。 SSL 是使用 *.myapp.com 的 Let’s Encrypt 通配符证书提供的。

现在,需要根据用户的偏好将应用映射到另一个域。例如,用户必须能够使用 Let's Encrypt 将 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 Rails 2.Nginx 3. 让我们加密

【问题讨论】:

    标签: ruby-on-rails nginx lets-encrypt


    【解决方案1】:

    您通常有 3 个步骤:

    1. 您的域的 DNS 必须有一个通配符,例如:*.domain.com
    2. 您必须有一个使用通配符的 Web 服务器配置,例如使用 Nginx:
      server_name *.domain.com;
      
      文档:http://nginx.org/en/docs/http/server_names.html
    3. 您的 Rails 应用程序必须在蓝图中放置 application_controller.rb 之类的代码

      User.find_by (subdomain: request.subdomain)
      

      要读取路径/路线,您必须使用constraints

      文档:https://guides.rubyonrails.org/routing.html#request-based-constraints

    【讨论】:

      猜你喜欢
      • 2016-12-18
      • 2018-10-17
      • 1970-01-01
      • 2019-05-17
      • 1970-01-01
      • 2017-11-20
      • 2019-05-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多