Hello, Every time when I try to tune my site from within (attachment), ISPConfig 3 will restore /etc/nginx/sites-available/example.com.vhost to its default, say: Code: root /var/www/example.com/web; 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.
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/example.com/web/public; 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: Code: ##subroot public ##
Code: ##subroot public ## till, you failed this time; because there is no such directive in Nginx official document: https://nginx.org/en/docs/dirindex.html
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.
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.
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.
I confirm that this works! but then, the ISPconfig statistics is useless for my case; because the web stat pages /var/www/example.com/web/stats/ is not accessible by me any more. Any traffic to /var/www/example.com/web/ is now redirected to /var/www/example.com/web/public/ Any one can provide a work-around for my case?
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.
Hello, my problem is little bit different: I would like to set the following: root /var/www/example.com/website/public; Is this possible? Thank you for your attention, Janos
Basically, you use delete and merge to achieve this. Try googling for: "site:forum.howtoforge.com root nginx directive".
The exact same question has been answered in post #3 in this thread, all you have to do is to enter: Code: ##subroot public ## in the nginx directives field.
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/example.com/website/public; But it makes: root /var/www/example.com/web/public; In other words I would like to rename "web" to "website" and create a folder in it, named "public" and /var/www/example.com/website/public to be the webroot. Thanks, Janos
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.
Till, 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! Janos