multi tenant with custom domain on rails

后端 未结 2 1271
野性不改
野性不改 2021-02-01 11:31

I\'m creating a multi tenant application like shopify and wanna know how can I create custom domain on server that points to the same application instance? For example:

2条回答
  •  鱼传尺愫
    2021-02-01 12:05

    I am currently working through something similar and just did the Nginx configuration. This is the way that I did it.

    server {
      listen 80;
      server_name domain1.com domain2.com domain3.com;
      rails_env production;
      passenger_enabled on;
      root /var/www/your_site_folder/current/public;
    }
    

    Also make sure to run passenger_pre_start if you are using passenger.

    ex: passenger_pre_start http://your_domain.com;

    Add one line for each domain that you add into the above config block.

    The key here is under server_name. Normally I would use this for a domain using www.domain.com or without the 'www', domain.com. But in this case you can point all domains that you want to hit your app from here and you have your Nginx setup for multi-tenancy.

提交回复
热议问题