Problem of Ngnix web config

Discussion in 'Installation/Configuration' started by concept21, Nov 3, 2022.

  1. concept21

    concept21 Active Member

    Every time when I try to tune my site from within (attachment),
    ngnix break.png

    ISPConfig 3 will restore /etc/nginx/sites-available/ to its default, say:
            root   /var/www/;
    However, my site must work with this line as:
    So, how do I improve this with some tune of the redirect feature or anything else? :(

    My OS is Ubuntu 20.04 + Nginx, ISPconfig 3.2.8.
  2. Benedict

    Benedict New Member HowtoForge Supporter

    See manual: Redirect proxy (nginx only). Page 130
    concept21 likes this.
  3. till

    till Super Moderator Staff Member ISPConfig Developer

    This means you manually entered an Nginx config that was rejected by Nginx because it is faulty, to avoid the whole server with all sites getting down in such a case, ispconfig restores the last working config. So your whole issue comes down to that you entered the wrong config in nginx directives field, and unless you fix that, you can not successfully save other changes to the site. For example, a config line like this:

    root /var/www/;

    in the nginx directive field is invalid, as Nginx does not support overriding the root path like this. To set the root directory of a site to folder named public inside web folder, use this line:

    ##subroot public ##
    concept21 and ahrasis like this.
  4. concept21

    concept21 Active Member

  5. till

    till Super Moderator Staff Member ISPConfig Developer

    I don't. Try it, then you see that it works ;) Nginx has no options to override configurations, that's why ISPConfig is able to circumvent this limit in the Nginx config parser. There are other options like ##merge## and ##delete## as well, search in the forum or see ISPConfig manual.
  6. concept21

    concept21 Active Member

    I also found that this guy's method worked! He is a Nginx expert!

    Redirect Type: proxy
    Redirect Path: /public/

    This is the official way, perhaps. :D
  7. ahrasis

    ahrasis Well-Known Member HowtoForge Supporter

    You are asking how to overwrite nginx vhost for a custom root in an ISPConfig nginx directive form, so to me @till is right as that is the official ISPConfig way to do so, not that I am denying proxy redirect may work as well, but I think it may have its own consequences.
  8. concept21

    concept21 Active Member

    Cool! Let me check. :eek:
  9. concept21

    concept21 Active Member

    I confirm that this works! :D

    but then, the ISPconfig statistics is useless for my case; because the web stat pages /var/www/ is not accessible by me any more.
    Any traffic to /var/www/ is now redirected to /var/www/

    Any one can provide a work-around for my case? :rolleyes:
  10. till

    till Super Moderator Staff Member ISPConfig Developer

    Of course, it works ;)

    That's what shall happen when you decide to change the web root of the Nginx virtual host, folders outside of the new web root become inaccessible. What you can try is to create a symlink in your new web root pointing to the stats folder.
    ahrasis likes this.
  11. jacsa

    jacsa New Member

    Hello, my problem is little bit different: I would like to set the following:
    root /var/www/;

    Is this possible? Thank you for your attention, Janos
  12. ahrasis

    ahrasis Well-Known Member HowtoForge Supporter

    Basically, you use delete and merge to achieve this. Try googling for: " root nginx directive".
  13. till

    till Super Moderator Staff Member ISPConfig Developer

    The exact same question has been answered in post #3 in this thread, all you have to do is to enter:

    ##subroot public ##
    in the nginx directives field.
  14. jacsa

    jacsa New Member

    Dear Till,
    thank you for your prompt reaction.

    But ##subroot public # makes a folder named "public" inside the "web" folder.
    I would like to have: root /var/www/;
    But it makes: root /var/www/;
    In other words I would like to rename "web" to "website" and create a folder in it, named "public" and /var/www/ to be the webroot.

    Thanks, Janos
  15. till

    till Super Moderator Staff Member ISPConfig Developer

    Generally, this is not a good idea as some things may start to fail, and some website features will not be available anymore for this site then. As you might know, Nginx, unlike Apache, does not allow config overriding. This means you can not specify different settings like a root path later in Nginx config to override an earlier setting. To work around this limitation, ISPConfig has a delete and merge mechanism for Nginx config in place, see the post from @ahrasis. But generally, it is a really bad idea to specify a different folder for the main website that is outside of the web folder, you can use alternate folders in vhost sub- and alias domains, though. So the question is, why you do not use a folder inside web.
  16. jacsa

    jacsa New Member

    yes I agree with you. In the meantime I agreed with developer to use /web/website/public. Thank you for your help, and also for ahrasis!
    ahrasis likes this.

Share This Page