Control Web Panel

WebPanel => Apache => Nginx => Topic started by: alimo on January 11, 2022, 07:55:54 PM

Title: vHost conf file keeps reseting to the orig, tpl file has some errors
Post by: alimo on January 11, 2022, 07:55:54 PM
I am using Apache-Nginx as the webserver. I want to allow all the HTTP methods (PUT, DELETE) on a host by changing the vHost file. When I change that via the "WebServers Configuration Editor" to add a line, it reverts to the template file after a while.

I tried adding a configuration via the "Manage WebServers Configuration" page, but the "All_methods" tpl file does not work. I can't successfully restart the httpd service, it complains about the conf file. I tried cloning the default tpl file to create my own template, but I can't make it work with my web current web serv Apache_nginx.

As the last option, I tried to edit the default.tpl and default.stpl file, it worked but I am just surprised that its back to the orig file now!
Title: Re: vHost conf file keeps reseting to the orig, tpl file has some errors
Post by: Netino on January 11, 2022, 11:52:50 PM
I am using Apache-Nginx as the webserver. I want to allow all the HTTP methods (PUT, DELETE) on a host by changing the vHost file. When I change that via the "WebServers Configuration Editor" to add a line, it reverts to the template file after a while.

I tried adding a configuration via the "Manage WebServers Configuration" page, but the "All_methods" tpl file does not work. I can't successfully restart the httpd service, it complains about the conf file. I tried cloning the default tpl file to create my own template, but I can't make it work with my web current web serv Apache_nginx.

As the last option, I tried to edit the default.tpl and default.stpl file, it worked but I am just surprised that its back to the orig file now!

You must avoid to change directly the vhosts/*.conf files.
They will always be overwritten when the webservers are rebuilt.

Instead of to change directly the vhosts conf files, you must create additional custom templates, simply copying and change them.
After that, you must apply the customized template to you site in CWP, "WebServers Domain Conf".

If you customize your webserver configuration, you *must* customize too the webserver templates in "/usr/local/cwpsrv/htdocs/resources/conf/web_servers/", otherwise, they will always be overwritten when CWP is updated.
(check there your webservers files used)

The templates per-si are *always* overwritten when CWP is updated too. So, you *must* to create additional files in that directories, instead to change it.
Copy an existant file, change the name of the file, one for .conf and another for .ssl.conf (always two files, obligatorily). This is needed to the template is showed in the "WebServers Domain Conf".

You can check this link to do it:
http://wiki.centos-webpanel.com/webservers-vhost-templates (http://wiki.centos-webpanel.com/webservers-vhost-templates)

One diverse way to avoid this customization above (in webserver templates) is to create your new custom files directly in 'conf.d' diretories of your webservers, avoiding to change the system config webserver files. You can use it, if possible.

Regards,
Netino
Title: Re: vHost conf file keeps reseting to the orig, tpl file has some errors
Post by: alimo on January 12, 2022, 08:44:40 AM
Why there is an editor there if the admin is not supposed to change the vHost file? The editor gives you a sense that you can edit it and it stays there! On the other hand, an static viewer gives you a sense that you can just see the contents and there is another way to edit it!

When I apply the custom templates via the "WebServers Domain Conf" page, I get 50x error. I can not restart apache if I select the default all_methods template. The spacing in that file is not correct. I only described one scenario for Nginx_apache, I have other problems on another VM where I try to change the Nginx vhost conf for my NodeJS app.

Lets just repeat that if I clone the default tpl file without any changes, I can not make it work. I've tried both "Nginx -> apache -> PHP-CGI" and "Nginx -> apache -> proxy" option. Maybe you need to give it a try yourself and give me more insights. Please note that I dont have php-fpm. I am using php switcher v2.
Title: Re: vHost conf file keeps reseting to the orig, tpl file has some errors
Post by: Netino on January 12, 2022, 09:06:36 PM
Why there is an editor there if the admin is not supposed to change the vHost file? The editor gives you a sense that you can edit it and it stays there! On the other hand, an static viewer gives you a sense that you can just see the contents and there is another way to edit it!

Yes, I agree: in my opinio,those files should be locked for editing, and there should be a warning that any changes will be overwritten in the next update. On the other hand, the documentation mentions that the changes made will be overwritten, so it is only possible to keep the changes with new files created from clones of those files.

Quote
When I apply the custom templates via the "WebServers Domain Conf" page, I get 50x error. I can not restart apache if I select the default all_methods template. The spacing in that file is not correct. I only described one scenario for Nginx_apache, I have other problems on another VM where I try to change the Nginx vhost conf for my NodeJS app.

Here is a problem with your template. After creating and applying it, you should check how it looks in your Apache or Nginx server configuration files. Check for errors, and fix templates.

Quote
Lets just repeat that if I clone the default tpl file without any changes, I can not make it work. I've tried both "Nginx -> apache -> PHP-CGI" and "Nginx -> apache -> proxy" option. Maybe you need to give it a try yourself and give me more insights. Please note that I dont have php-fpm. I am using php switcher v2.

When creating a .tpl file, it is mandatory to also create its corresponding .stpl file, or the template will not be available to be chosen and assigned to your site, either for PHP-FPM or PHP-CGI.