Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to configure subdomain for multitenant installation #50

Open
filos1983 opened this issue Jun 2, 2020 · 7 comments
Open

How to configure subdomain for multitenant installation #50

filos1983 opened this issue Jun 2, 2020 · 7 comments

Comments

@filos1983
Copy link

Hello,

thanks, for your guide, it's great. I've just one doubt: how should I configure my installation to support more than one organisation?
Now my domain is decidim.test and, if I add an organisation with host decidim.test and open that page, I've that organisation login form. When I add a second organisation I should use a different host (org2.decidim.test) but obviously it doesn't work and at that page I just see an nginx error. Which is the correct way to configure multi-tenancy? Which are the files I should edit?

Thanks

@microstudi
Copy link
Contributor

when you say that you are using decidim.test, you mean literally? .test domains are for... testing.

If that's the case you need to add in your /etc/hosts system all the domains you want to test to point to localhost (or 127.0.0.1).

As a general case, you need to point any domain or subdomain used for a tenant to the server you are using, then go to anyworkingdomain.tld**/system**, log in there and configure the other tenant, you need to add the full subdomain there as the name of the tenant host.

@filos1983
Copy link
Author

Yes, domain is .test because is a local domain I use to learn how decidim works :) Thanks for your reply: i've added org2.decidim.test and org1.decidim.test to /etc/hosts but I can't reach the tenants' login pages even though i can ping those domains. So, I've tried to edit /etc/nginx/decidim.conf (now the line server_name is *.decidim.test) and now i can open both tenants; unfortunately, i can't see anymore the /system logon page, just the nginx message: "If you see this page, the nginx web server is successfully installed and working. Further configuration is required". Probably I'm missing something in nginx configuration or DNS, I should check.

@microstudi
Copy link
Contributor

Clearly nginx is not reaching passenger (or puma), try to post here the nginx configuration

@filos1983
Copy link
Author

After some tests now i've this environment: one domain decidim.test with two organisations (decidim.test and org2.decidim.test). I can login in /system page and in decidim.test tenant; when i try to login in org.decidi.test there's an Nginx error: "If you see this page, the nginx web server is successfully installed and working. Further configuration is required"

This is my mod-http-passenger.conf

passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini;
passenger_ruby /home/decidim/.rbenv/shims/ruby;

Here nginx.conf

user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
        worker_connections 768;
        # multi_accept on;
}

http {

        ##
        # Basic Settings
        ##

        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;
        # server_tokens off;

And here my sites-enabled/decidim.conf

server {
    listen 80;
    listen [::]:80 ipv6only=on;

    server_name decidim.test;
    client_max_body_size 32M;

    passenger_enabled on;
    passenger_ruby /home/decidim/.rbenv/shims/ruby;

    rails_env    production;
    root         /home/decidim/decidim-app/public;
}

@microstudi
Copy link
Contributor

I'd say you have the problem in your decidim.conf file, try to use "_" and "default_server" in it:

server {
    listen 80 default_server;
    listen [::]:80 ipv6only=on;

    server_name decidim.test _;
    client_max_body_size 32M;

    passenger_enabled on;
    passenger_ruby /home/decidim/.rbenv/shims/ruby;

    rails_env    production;
    root         /home/decidim/decidim-app/public;
}

@filos1983
Copy link
Author

I've tried to edit decidim.conf file but nginx can't be restarted with the following error

2020/06/11 17:47:59 [emerg] 2259#2259: a duplicate default server for 0.0.0.0:80 in /etc/nginx/sites-enabled/default:22
2020/06/11 17:47:15 [emerg] 2226#2226: a duplicate default server for 0.0.0.0:80 in /etc/nginx/sites-enabled/default:22

The problem is with line listen 80 default_server;

@microstudi
Copy link
Contributor

the remove the other configuration file, you cannot have to defintions of default_server as the message stands

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants