0

I have a Rails app that supports sub-domains right now. Users can have URLs like abc.myapp.com. The SSL is provided using Let’s Encrypt Wildcard Certificate for *.myapp.com.

Now, the app needs to be mapped to another domain according to the user’s preference. Like, users must be able to map abc.myapp.com to hello.otherapp.com With Let’s Encrypt.

Here are some references for what I am talking about: 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

My stack is: 1. Ruby on Rails 2. Nginx 3. Let’s Encrypt

Karthik Kamalakannan
  • 770
  • 1
  • 11
  • 31

1 Answers1

-1

You have 3 steps in general:

  1. The DNS for your domain must have a wildcard, such as: *.domain.com
  2. You must have a Web Server configuration using wildcards, for example using Nginx:
    server_name *.domain.com;
    
    documentation: http://nginx.org/en/docs/http/server_names.html
  3. Your Rails application must have in blueprint placed like application_controller.rb with code like

    User.find_by (subdomain: request.subdomain)
    

    and to read the path / route you must use constraints.

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

SunDi3yansyah
  • 46
  • 1
  • 7