custom teplate: where insert empty nginx.conf

Discussion in 'General' started by maumar, Jun 1, 2017.

  1. maumar

    maumar Member HowtoForge Supporter

  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Custom config file templates go into the folder /usr/local/ispconfig/server/conf-custom/
     
    maumar likes this.
  3. maumar

    maumar Member HowtoForge Supporter

    Ok, so I have created an empty nginx.conf into /usr/local/ispconfig/server/conf-custom/
    # touch /usr/local/ispconfig/server/conf-custom/nginx.conf
    so, the next nginx virtualhost I will create on this server,
    there will be an empty nginx.conf file into /var/www/nomesito/web/ ?

    I just have tried and no nginx.conf was got created

    total 32
    drwxr-x--x 4 web5093 client20 4096 Jun 4 09:01 .
    drwxr-xr-x 8 root root 4096 Jun 4 09:01 ..
    drwxr-xr-x 2 web5093 client20 4096 Jun 4 09:01 error
    -rwxr-xr-- 1 web5093 client20 7358 Jun 4 09:01 favicon.ico
    -rwxr-xr-- 1 web5093 client20 1861 Jun 4 09:01 index.html
    -rwxr-xr-- 1 web5093 client20 14 Jun 4 09:01 robots.txt
    drwxr-xr-x 2 web5093 client20 4096 Jun 4 09:01 stats

    I have created it into /usr/local/ispconfig/server/conf-custom/index/
    w/out success, creating a new website nginx.conf is not created inside it

    ls -la /usr/local/ispconfig/server/conf-custom/index/
    total 12
    drwxr-s--- 2 root root 4096 Jun 4 09:06 .
    drwxr-s--- 6 root root 4096 Jun 4 08:21 ..
    -rwxr-x--- 1 root root 45 Apr 3 00:01 empty.dir
    -rwxr-x--- 1 root root 0 Jun 4 09:06 nginx.conf
     
    Last edited: Jun 4, 2017
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    The template file of nginx is not named nginx.conf. Look at the templates folder /usr/local/ispconfig/server/conf/ to see how the files are named and your custom template override file must have the exact same name then the original template, the name of the nginx config file of the website is nginx_vhost.conf.master. An empty nginx configuration file will result a non-working site as the website will not exist in nginx then, but the folders will be created of course. I have no idea what you might need this for, I just wanted to notify you that you should not expect to get a working site by using an empty nginx config template for the website.

    The only possible reason that I can see is that you want to write all config files manually on the shell, but why use ISPConfig then on this server?

    The folder /usr/local/ispconfig/server/conf-custom/index/ is not for configuration templates, it is for the default index file (index.html) and the error pages of the website.

    The nginx configuratiion file is not in the folder /var/www/nomesito/web/ when active, the nginx configuration files of the websites are in /etc/nginx/sites-available/ folder.
     
    Last edited: Jun 4, 2017
  5. maumar

    maumar Member HowtoForge Supporter

    Sorry to have been misleading :(
    the matter is very simple: we host at 99% wordpress
    All wordpress sites use permalinks and we add into Options tab following piece of configuration, the one you suggested in other posts:

    Code:
    location / {
      try_files $uri $uri/ /index.php?$args;
      }
      rewrite /wp-admin$ $scheme://$host$uri/ permanent;
      location ~* \.(jpg|jpeg|png|gif|css|js|ico)$ {
      expires max;
      log_not_found off;
      }
      include /var/www/Namewebsite/web/nginx.conf;
      location ~ /nginx.conf {
      deny all;
      access_log off;
      log_not_found off;
      }
    
    
    changing Namewebsite with proper values.
    Next step is to upload nginx.conf empty into /var/www/Namewebsite/web/
    to get /var/www/Namewebsite/web/nginx.conf in place
    Code:
    include /var/www/Namewebsite/web/nginx.conf;
    
    request an nginx.conf file to exist, even empty, otherwise an .err vhost file is generated

    Many times who should upload this empty file, forget to do it.
    This suggests me to add this file to nginx web site template,
    so it would not be up to someone to create it, but up to your scripts

    Hopefully this is more clear then previous posts.
    If you create an .htaccess empty file into apache new virtualhosts, why do not create nginx.conf into nginx new virtualhosts?
     
    Last edited: Jun 4, 2017
  6. till

    till Super Moderator Staff Member ISPConfig Developer

    Ahh ok, sorry. I completely misunderstood you.

    Personally, I won't use a line include /var/www/Namewebsite/web/nginx.conf; in the nginx directives file as it might allow any client on your server to take over the system or at least it allows him to kill nginx for all sites that you host. For that reason, the apache directives field in ISPConfig is only available to the admin and not the client and ispconfig is testing the config which will also not happen for this include. With this include line, you allow clients to modify the nginx config of the whole server which is extremely risky.

    If you are aware of these risks and want to take them anyway, then you will have to create a custom ispconfig plugin to create that file by attaching it to the website insert event.
     
    maumar likes this.
  7. maumar

    maumar Member HowtoForge Supporter

    Hello,
    yes, I agree, with this include line, you allow clients to modify the nginx config of the whole server which is extremely risky.
    But there are a lot of plugin, security plugin like iThemeSecuity, that write on .htacces with apache, in nginx.conf with nginx web server.
    So, if I use nginx.conf, I should include it in global server configuration.
    Otherwise, where iThemeSecurity and all the other plugins should write configuration?
    many thnx
     
  8. till

    till Super Moderator Staff Member ISPConfig Developer

    Nginx does not offer an option that tools which run inside the website can write such config securely as done in apache with .htaccess.
     

Share This Page