Multi Domains

Create multiple domains or url and bind this to arbitry theme or page/staticpage with extending routing rules use single CMS installation (support backend)

Back to Multi Domains Support

luc.petitjean61931
luc.petitjean61931

Good afternoon,

I just bought your plugin which seems ideally made for my usage but actually it doesn't work.

At the install i got a SQL error even that plugin is there and active.

"SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'fullinterface' (SQL: alter table linkonoid_mdomains_settings add fullinterface tinyint(1) not null default '0')" on line 664 of /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php

I made the install yesterday, even that that the version 1.4.4 that is installed.

When i try to make the update i got the same SQL error. It occurs also when i try to install a new theme.

I register to domain with a specific theme for each. Both domain are loading the active themes set in the backend and when i try to switch of front theme no error occured but it is still the default one which is active. I run on octoberCMS 465.

Thanks for your support.

Luc Petitjean.

Linkonoid
Linkonoid

Hi Luc,

Thanks for the information! I checked. Indeed, an error is issued at the migration stage (as it turned out, there is an error in the version-update file with the repeated call of one and the same migration file, I will update install file today), but this not affect the plugin.

Last updated

luc.petitjean61931
luc.petitjean61931

Dear,

Thanks for the quick reply what could explain that theme is not switched following the related domain?

Thank you.

Linkonoid
Linkonoid

Enable "Enable hard mode replacing original cms Router" in the settings. And yes, there are still problems with migration - the current version is 1.4.8 (please wait until the plugin update is completed on the marketplace - 1-2 hours)

luc.petitjean61931
luc.petitjean61931

I already tried to enable "Enable hard mode replacing original cms Router" but without success. I'll let you now if update will work.

Linkonoid
Linkonoid

Plugin update to v1.4.9. Please update, reinstall or full remove plugin and install. Please note that before deleting by means of CMS, you need to turn off the substitution of the router (otherwise you can get unpredictable behavior), in addition, you can check the contents of the router file for the presence of my extended code

Last updated

Linkonoid
Linkonoid

In addition, you can see examples of configurations on my MDomains test server (mdomains/admin): https://mdomains.test.linkonoid.com/backend

(v1.4.9 on 469 BUILD)

Last updated

luc.petitjean61931
luc.petitjean61931

Good morning,

I tested it and it works well on my local setup. Reinstall on my production server gives the same results (theme switch is not working)

What do you mean by: in addition, you can check the contents of the router file for the presence of my extended code

Thank you.

Linkonoid
Linkonoid

Hello,

I mean, when you uninstall the plugin or reinstall it, the replaced non-original router may be overwritten by the original one and the replacement switch will fail (plugin don't track the contents of the file), then turn it on and off and again then turn it (though the original router will be lost if there was a substitution).

If all domains running locally - first check the virtual hosts setup on the server and have DNS for them - they should all be looking at the only October installation with the plugin enabled.

And check if you have the default theme enabled in your settings.

Last updated

luc.petitjean61931
luc.petitjean61931

Hi,

I switch it off and on twice without success.

I got DNS and here is my nginx configuration for virtual hosts

    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_pass http://localhost:8088;

Default theme is well enabled.

Thank you.

Luc.

Linkonoid
Linkonoid

I see from the settings only proxying to the local host. You must have virtual hosts configured in nginx (where a set working folder with OctoberCMS is set for each virtual domain or their list) and on the DNS server present A or CNAME (better A record) -records for the corresponding domains pointing to one IP address - address of your working server

Last updated

luc.petitjean61931
luc.petitjean61931

I forgot to specify that we use a docker container.

About DNS i got two A record pointing to my server and nginx proxy to the docker container. On local environnement i use hosts file also with docker.

I guess, it is the same behaviour.

Last updated

Linkonoid
Linkonoid

The presented nginx config above works as a proxy (there is no complete information, but I guess that for a container), in any case, you have second nginx or a similar server deployed somewhere (in a container?). And host must be registered indicating the October working folder (how will you serve virtual hosts? - all hosts have one IP)

Last updated

Linkonoid
Linkonoid

luc.petitjean61931 said:

I forgot to specify that we use a docker container.

About DNS i got two A record pointing to my server and nginx proxy to the docker container. On local environnement i use hosts file also with docker.

I guess, it is the same behaviour.

Do you have 2 different IP on DNS records?

luc.petitjean61931
luc.petitjean61931

Linkonoid said:

luc.petitjean61931 said:

I forgot to specify that we use a docker container.

About DNS i got two A record pointing to my server and nginx proxy to the docker container. On local environnement i use hosts file also with docker.

I guess, it is the same behaviour.

Do you have 2 different IP on DNS records?

No only one IP.

Linkonoid
Linkonoid

I'm not quite clear why proxying through nginx? Place nginx in a container, pulling the config and october outside, something like this (set up paths and ports In:Out if you use non-standard ports, A-record DNS Ip for sub1.domain.tld = Ip for sub2.domain.tld = Server IP):

$ docker run --name nginx-container-name \
               -p 80:80 -d \
               -v /home/core/www:/usr/share/nginx/html/octobercms:ro \ 
               -v /home/core/nginx.conf:/etc/nginx/nginx.conf:ro \
               --restart=always nginx

And nginx.conf:

user  nginx;
worker_processes  1;
error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;

events {
  worker_connections  1024;
}

http {
 server {
    listen 80;
    server_name sub1.domain.tld;
    root /usr/share/nginx/html/octobercms;
    index index.php;
    location ~ \.php$ {
        fastcgi_pass php-fpm:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
  }
  server {
    listen 80;
    server_name sub2.domain.tld;
    root /usr/share/nginx/html/octobercms;
    index index.php;
    location ~ \.php$ {
        fastcgi_pass php-fpm:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
  }
  include /etc/nginx/conf.d/*.conf;
}

And if php-fpm in container:
$ docker run --name php-fpm-container-name \
               -p 9000:9000 -d \
               -v /public:/usr/share/nginx/html/octobercms:ro \

Last updated

Linkonoid
Linkonoid

In addition, if I understand correctly, you can do without containers at all (you still use Nginx outside the container to proxy to the container, though I didn't quite understand what is inside it)

luc.petitjean61931
luc.petitjean61931

Dear,

About the container i followed this tutorial page: https://blog.programster.org/deploy-october-cms-with-docker.

Could you please explain me what i need to check about the original router replacement?

Thank you.

Luc.

luc.petitjean61931
luc.petitjean61931

I checked modules/cms/classes/Router.php

  • On working local: file is not modified
  • On non working production: file is modified

All logic is based on $url of this file?

Thank you.

Last updated

luc.petitjean61931
luc.petitjean61931

Hi,

I just installed this free plugins which make the trick about the theme: https://bitbucket.org/keiosdevs/oc-multisite/src/master/

/*
         * Listen for CMS activeTheme event, change theme according to binds
         * If there's no match, let CMS set active theme
         */
        Event::listen(
            'cms.theme.getActiveTheme',
            function () use ($binds, $currentHostUrl) {
                foreach ($binds as $domain => $bind) {
                    if (preg_match('/'.$currentHostUrl.'/i', $domain)) {
                        Config::set('app.url', $domain);

                        return $bind['theme'];
                    }
                }
            }
        );

I hope you will ba able to help me.

Best regards.

Luc.

1-20 of 25