Is it possible to let users have custom domain point to my app with https auto enable for them.

September 6, 2018 623 views
Applications Ruby on Rails Nginx Ubuntu 16.04

If I want to launch Ruby on Rails website where users can have their dedicated page
1.) as sub domain i.e. user-subdomain-name.my-service.com
2.) as custom domain i.e. user-custom-domain-name.com

and also enabled https for both subdomain and custom domain.

Is it possible to do this automatically? Let say once my app get this information from user I run some script to make this happen.

1 Answer

@sarunw you should be able to do something like the following in your nginx configuration:

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    server_name _;
    return 301 https://$host$request_uri;
}
  • If I understand correctly that redirect all http to https right? like a force https.

    But I want something like Medium.com where user can point that custom domain to medium.com/their-user-name and enable https (may be via Let’s encrypted) for them.

  • @mwilliamsdev Any security/performance concern with this catch app server_name approach?

Have another answer? Share your knowledge.