Nginx custom configuration per site

Hi everyone, I’m very new to HestiaCP and I must say that so far I love it, very well done!

I’m having some difficulties on understanding how can I edit a single site Nginx configuration. I thought that I just had to clone an existing configuration from here /usr/local/hestia/data/templates/web/nginx/php-fpm and then select it as template for the site, however if I do so, despite I reload Nginx, I do not see the changes.
I am able to see the changes only if I manually edit the file at /home/site.com/conf/web/site.con/nginx.ssl.conf.

What am I doing wrong?

Hi @Ade,

Once you modify a template, you must rebuild the web domain to apply the changes.

From GUI:

From command line:

v-rebuild-web-domain USER DOMAIN [RESTART]

Example using test as user, example.net as domain and yes to restart the web services.

v-rebuild-web-domain test example.net yes

Also, keep in mind that /usr/local/hestia/data/templates/web/nginx/php-fpm/ templates are for Nginx standalone, if you are using Nginx+Apache, the proxy templates are her /usr/local/hestia/data/templates/web/nginx/ and apache templates here /usr/local/hestia/data/templates/web/apache2/php-fpm/

Hey @sahsanu thank you very much for the quick reply, I missed that step, I’ll try right away!
I’m using Nginx standalone so I should be good using those templates, thank you for confirming!
Shall I install extras like libnginx-mod-http-lua manually via apt install nginx-extras or is there a way via the HestiaCP GUI?

You are welcome.

There is no way from web UI, you should install it via apt BUT, those packages; libnginx-mod-http-* and nginx-extras are created by Debian/Ubuntu for their Nginx version and Hestia doesn’t use it, Hestia uses mainline Nginx directly from nginx.org repositories.

Oh I see, so no way to add Lua support to the current setup?

I don’t think so but I’m not using those modules so no idea if there would be a fancy way but…

If you run nginx -V you will see the options used to compile the software and lua is not there.

$ nginx -V
nginx version: nginx/1.25.5
built by gcc 12.2.0 (Debian 12.2.0-14) 
built with OpenSSL 3.0.9 30 May 2023 (running with OpenSSL 3.0.11 19 Sep 2023)
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-http_v3_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-g -O2 -ffile-prefix-map=/data/builder/debuild/nginx-1.25.5/debian/debuild-base/nginx-1.25.5=. -fstack-protector-strong -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -Wl,--as-needed -pie'
$ nginx -V 2>&1 | grep -i lua
$

Gotcha, I need to check if I can have Nginx executing a bash command/script without the use of Lua then :thinking:. I see that a user can clear fastcgi cache from the Hestia panel but I’d like to create a MU plugin for the CMS so that it can be cleared from the site admin area too. I’ll make some test. Thank you for all the details @sahsanu :+1:

@Ade I would be interested to know if you are able to get this working — and how. I have a similar need (in my case for Joomla).

Hey @Bruce27 :wave: , I did get it to work.
I have broken the Nginx installation first though :sweat_smile: so if you want to try it try it on staging server if you have one.

I’ve installed the extras via apt, Nginx broke, I’ve then used the solution I found here and once I used nginx -V again I found the Lua module to be available.

--http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-compat --with-pcre-jit --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_v2_module --with-http_dav_module --with-http_slice_module --with-threads --with-http_addition_module --with-http_flv_module --with-http_geoip_module=dynamic --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module=dynamic --with-http_mp4_module --with-http_perl_module=dynamic --with-http_random_index_module --with-http_secure_link_module --with-http_sub_module --with-http_xslt_module=dynamic --with-mail=dynamic --with-mail_ssl_module --with-stream=dynamic --with-stream_ssl_module --with-stream_ssl_preread_module --add-dynamic-module=/build/nginx-qv2Nx5/nginx-1.18.0/debian/modules/http-headers-more-filter --add-dynamic-module=/build/nginx-qv2Nx5/nginx-1.18.0/debian/modules/http-auth-pam --add-dynamic-module=/build/nginx-qv2Nx5/nginx-1.18.0/debian/modules/http-cache-purge --add-dynamic-module=/build/nginx-qv2Nx5/nginx-1.18.0/debian/modules/http-dav-ext --add-dynamic-module=/build/nginx-qv2Nx5/nginx-1.18.0/debian/modules/http-ndk --add-dynamic-module=/build/nginx-qv2Nx5/nginx-1.18.0/debian/modules/http-echo --add-dynamic-module=/build/nginx-qv2Nx5/nginx-1.18.0/debian/modules/http-fancyindex --add-dynamic-module=/build/nginx-qv2Nx5/nginx-1.18.0/debian/modules/nchan --add-dynamic-module=/build/nginx-qv2Nx5/nginx-1.18.0/debian/modules/http-lua --add-dynamic-module=/build/nginx-qv2Nx5/nginx-1.18.0/debian/modules/rtmp --add-dynamic-module=/build/nginx-qv2Nx5/nginx-1.18.0/debian/modules/http-uploadprogress --add-dynamic-module=/build/nginx-qv2Nx5/nginx-1.18.0/debian/modules/http-upstream-fair --add-dynamic-module=/build/nginx-qv2Nx5/nginx-1.18.0/debian/modules/http-subs-filter --add-dynamic-module=/build/nginx-qv2Nx5/nginx-1.18.0/debian/modules/http-geoip2

Once Lua was available I was able to create my MUplugin so that fastcgi cache can be cleared within the WordPress admin area