map directive not allowed here, nginx magento multistore ispconfig

Discussion in 'ISPConfig 3 Priority Support' started by itsolon, Mar 19, 2018.

  1. itsolon

    itsolon Member

    Hello together
    now next issue i try to fix:)
    Magento multistore i want to have multiple websites within one single magento installation as i have it with apache.

    SetEnvIf Host www\.domain\.com MAGE_RUN_CODE=base
    SetEnvIf Host www\.skantek\.net MAGE_RUN_TYPE=website
    SetEnvIf Host ^skantek\.net MAGE_RUN_CODE=base
    SetEnvIf Host ^skantek\.net MAGE_RUN_TYPE=website

    SetEnvIf Host www\.m1map1.domain\.com MAGE_RUN_CODE=m1map1
    SetEnvIf Host www\.m1map1.domain\.com MAGE_RUN_TYPE=website
    SetEnvIf Host ^m1map1.domain\.com MAGE_RUN_CODE=m1map1
    SetEnvIf Host ^m1map1.domain\.com MAGE_RUN_TYPE=website

    if i set map directives inside my ispconfig panel

    map $http_host $magecode {
    hostnames;
    .m1.domain.com base;
    .m1map1.domain.com m1map1;
    .m1map2.domain.com m1map2;
    }

    but i cannot set map directives as they need to be on other place obviously

    nginx: [emerg] "map" directive is not allowed here in /etc/nginx/sites-enabled/100-m1.itsolon.com.vhost:80
    nginx: configuration file /etc/nginx/nginx.conf test failed

    perhaps i have to set mage storecode with an if clause??

    location ~ ^/(?<uri_prefix>(nl|be)) {
    if ($uri_prefix = be) {
    set $storecode "storeview_be";
    }
    if ($uri_prefix = nl) {
    set $storecode "storeview_nl";
    }
    rewrite / /$uri_prefix/index.php break;

    location ~ \.php$ {
    echo_exec @phpfpm;
    }
    }

    Help greatly appreciated
    Markus
     
    Last edited: Mar 19, 2018
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    You can not use the map directive within a nginx vhost. If you want to use it, you will have to write your own vhost file or modify the current one manually and make it immutable with the chattr command so that ispconfig is not able to alter it.
     
  3. itsolon

    itsolon Member

    hmm then edit outside admin panel and make readonly?
    how you would solve such a task?
    how about some if solution? to set the storecode?

    location ~ ^/(?<uri_prefix>(nl|be)) {
    if ($uri_prefix = be) {
    set $storecode "storeview_be";
    }
    if ($uri_prefix = nl) {
    set $storecode "storeview_nl";
    }
    rewrite / /$uri_prefix/index.php break;

    location ~ \.php$ {
    echo_exec @phpfpm;
    }
    }
     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    Using if is probably the better option anyway as a map is global, so as soon as you would try to add a second magento host by using a map, the maps would collide.
     
  5. itsolon

    itsolon Member

    i tried it with nginx now it seems that it could work?

    vhostfile #1
    Code:
    map $http_host $magecode {
    hostnames;
    .m2.domain.com base;
    .m2map1.domain.com m2map1;
    .m2map2.domain.com m2map2;
    }
    vhostfile #2
    Code:
    map $http_host $magecode {
    hostnames;
    .m1.domain.com base;
    .m1map1.domain.com m1map1;
    .m1map2.domain.com m1map2;
    }
    root@web:/etc/nginx/sites-available# nginx -t
    nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
    nginx: configuration file /etc/nginx/nginx.conf test is successful

    if so, there is a field missing inside ispconfig
    so that i can enter map directives . when i need them

    can i reuse some function an easy one with no checks
    i have seen that your nignx-directives has a lot of checks inside

    is there any easy one like snippets? field without checks?
     
  6. till

    till Super Moderator Staff Member ISPConfig Developer

    There is no function to add code outside of a vhost.
     
  7. itsolon

    itsolon Member

    but i could add something like a field inside the admin
    and then fill the vhost files with it like shown below

    Code:
    <tmpl_loop name="nginx_map_directives">
            <tmpl_var name='nginx_map_directive'>
    </tmpl_loop>
    
    server {
            listen <tmpl_var name='ip_address'>:<tmpl_var name='http_port'>;
    <tmpl_if name='ipv6_enabled'>
            listen [<tmpl_var name='ipv6_address'>]:<tmpl_var name='http_port'>;
    </tmpl_if>
          
    <tmpl_if name='ssl_enabled'>
            listen <tmpl_var name='ip_address'>:<tmpl_var name='https_port'> ssl http2;
        ssl_prot
     
  8. itsolon

    itsolon Member

    i have seen that to have a new field that i can use in admin i would have to edit database structure of
    web_domain
    and then after the next update problems could occur

    another thought is to rewrite the nginx_directives function
    with some "map" recognition.?
     

Share This Page