使用Rails + Nginx +加密实时创建自定义域

问题描述 投票:0回答:1

我现在有一个支持子域的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.让我们加密

ruby-on-rails nginx lets-encrypt
1个回答
0
投票

您通常有3个步骤:

  1. 您所在域的DNS必须具有通配符,例如:*.domain.com
  2. 您必须具有使用通配符(例如,使用Nginx的Web服务器配置:
    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

© www.soinside.com 2019 - 2024. All rights reserved.