How do I put directives outside of the server{} block?

Discussion in 'Server Operation' started by fbarcenas, May 11, 2017.

  1. fbarcenas

    fbarcenas Member

    I have an ISPCONFIG NGINX perfect server.
    To be able to host a multisite wordpress, I need to put things outside of the server{} block as per this link:
    If I use the directives section in the website>options tab, that will only fall inside of the server{} block.

    I need to add this outside of the server block:
    map $http_host $blogid {
        default 0;
        include /var/www/pathtoyoursite/wp-content/uploads/nginx-helper/map.conf;
    Any ideas?
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Are you really sure that this is needed. I would setup a WP multisite in nginx the way that is described here:

    Basically you just add this in the nginx directives field of the website in ISPConfig:

    location / {
    try_files $uri $uri/ /index.php?$args ;
    then you add a mysql db in ispconfig and then start with step four of the above tutorial.

    Additional websites get simply added by adding alias domains in ISPConfig for this site first and then continue to configure them in WP. There should be no additional configuration in nginx be required.
  3. fbarcenas

    fbarcenas Member

  4. Tekati

    Tekati ISPConfig Developer ISPConfig Developer

    WordPress MultiSite is a strange beast. It works but keep in mind that it places all tables in one database. So if you are good with that then go for it. That same tutorial works just select sub directories instead of sub domains which makes your job even easier. Less DNS hassle when setting up new sites. You can get a plugin called Domain Mapper can't remember the vendor but search for it that allows you to make things like
    be accessible by
  5. Stephan Ververda

    Stephan Ververda Member HowtoForge Supporter

    Like the TS i'm running into the same problem. Yes the directive needs to be placed outside of the server {} block.
    Running multisite (w/sub-directories) is the preferred solution as opposed to running multisite (w/sub-domains) for SEO purposes. As a multisite on multiple subdomains gets treated as seperate sites by the search engines. For instance, if you run a webshop in multiple languages and you have reviews on a certain product in all languages, in a multisite with subdirectories you get better ranking scores on your domain as opposed as having multiple sub-domains.
    Now the specific directive in combination with the wordpress plugin makes it so that if a post get's updated the cache will be cleared. And caching is another argument for SEO purposes as since Google started treating mobile searches being more important the speed of the page loading is another important ranking factor for SEO.

    So for the TS just the be clear, the map directive is not a necessity, however if speed of page loading is important, especially for SEO reasons it's a must be "option".

    I'm not sure, but i have a feeling that as long as ISPConfig does not need to rewrite the site.conf file for nginx, you can manually edit the file after configuring the site in ISPConfig. But changing the site config from ISPConfig will rewrite the site.conf file making your change dissapear.
  6. Stephan Ververda

    Stephan Ververda Member HowtoForge Supporter

    Sorry for the spam, but i needed an additional post for being able to create a hyperlink

    I manually edited the site.conf ( inside the /etc/nginx/sites-available/ with the necesarry directives and it's working fine. Then for safety i created a backup copy of that file just in case. So far it seems to be working fine.
    However i now did this for only one site as i'm still in the testing stage of setting up my hosting server, doing this kind of thing in the end for my clients is of course a lot of manual labor and monitoring, especially as i'm trying to set up a hosting service that is going to be marketed for safe, reliable and optimized for performance webhosting and to be combined with my other business of SEO optimilization.
    Last edited: May 22, 2017

Share This Page