Two countly instances on one server


#1

I want to run two countly instances on one server. So I created two directories where I run the
bash countly.install.sh command. So countly is installing the nginx by default. So I had to configure them like described in this topic. Directories are the following ones:

/var/www/html/prod
/var/www/html/dev

I want to have the following subdomains:

prod.my-domain.com
dev.my-domain.com

The nginx server has the configuration files:

/etc/nginx/sites-available/prod.my-domain.com
/etc/nginx/sites-available/dev.my-domain.com

Both sites are enabled or in other words the files have shortcuts like so:

/etc/nginx/sites-enabled/prod.my-domain.com
/etc/nginx/sites-enabled/dev.my-domain.com

Each file looks like this. Of course the dev.my-domain.com-file has dev.my-domain.com where prod.my-domain.com is written and the document root is /var/www/html/dev instead of /var/www/html/prod.

server {
        listen 80;
        listen [::]:80;
        server_name prod.my-domain.com;
        return 301 https://$host$request_uri;
}

server {
        server_name prod.my-domain.com;
        listen 443 ssl;
	listen [::]:443 ssl;

	root /var/www/html/prod;

	ssl on;
  	ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  	ssl_prefer_server_ciphers on;
  	ssl_ciphers 'kEECDH+ECDSA+AES128 kEECDH+ECDSA+AES256 kEECDH+AES128 kEECDH+AES256 kEDH+AES128 kEDH+AES256 DES-CBC3-SHA +SHA !aNULL !eNULL !LOW !kECDH !DSS !MD5 !EXP !PSK !SRP !CAMELLIA !SEED';
  	ssl_session_cache builtin:1000 shared:SSL:10m;
  	ssl_stapling on;
	ssl_dhparam /etc/nginx/ssl/dhparam2048.pem;
        ssl_certificate /root/my-domain.com.chain.crt;
        ssl_certificate_key /root/my-domain.com.key;
	
	access_log  off;

	location = /i {
		proxy_pass http://127.0.0.1:3001;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_set_header X-Real-IP $remote_addr;
	}
	
	location ^~ /i/ {
		proxy_pass http://127.0.0.1:3001;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_set_header X-Real-IP $remote_addr;
	}

	location = /o {
		proxy_pass http://127.0.0.1:3001;
	}
	
	location ^~ /o/ {
		proxy_pass http://127.0.0.1:3001;
	}

	location / {
		proxy_pass http://127.0.0.1:6001;
		proxy_set_header Host $http_host;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_set_header X-Real-IP $remote_addr;
	}
}

Now if I want to access dev.my-domain.com the browser holds the correct url but shows the content from prod.my-domain.com. I know that because I installed the dev directory fresh and normally it should show me the setup screen instead of the login page. I'm not that familiar with nginx. I took the configuration right from the countly server installation documentation. So is maybe something wrong with the nginx confiurations or is there something in countly itself which denied my will.

Can someone give me an advice how to proceed here?


#2

Hello,
it would not be possible actually. Because they will use the same database either way.

Your current problem are probably ports, I assume both nginx configs point to 3001 api and 6001 frontend nodejs processes, that can be changed on one server's config files and modify nginx to point to other ports configured

But the problem still comes down to using same database. Since they will share data, there is no point in having separate servers


#3

Why do they share they same database? Is the database installed globally? I thought the database is stored inside the directory where I installed countly. The idea behind the two countly instances is simply that we normaly use apache for our servers. So I can't install countly without having issues on our apache running servers. So I thought we could run two instances on the server where only nginx is running. Also we want to have two instances so that we can test some stuff without modifying our production data.

But in conclusion you say its not possible right?


#4

It uses MongoDB which is installed globally on the same server.
So it connects to database server and uses it. That's why they will share the data.

I guess there could be a way, but might require lots of experimenting. But in overall, Countly is not designed to run that way. In most cases Countly is single software with dedicated server or VM.

But about apache, we don't require to use nginx specifically, so if you can configure apache to point to same paths same nodejs processes as nginx does, you can use apache instead of nginx.


#5

Alright. Thanks for your help