Vannkorn

Full Stack Web Developer

Close

Website ends up with 421 redirect after Hestia CP update

Due to the discussion at the Hestia CP forum, it turns out that the latest update of Hestia CP broke the nginx default stpl template.

Ads: Register now via this link to receive $300 credit from Vultr

One of the websites I hosted for a client experienced a weird error message, 421 Misdirected Request, after Hestia Control Panel updated in the background.

Misdirected Request

The client needs a new connection for this request as the requested host name does not match the Server Name Indication (SNI) in use for this connection.

Due to the discussion at the Hestia CP forum, it turns out that the latest update of Hestia CP broke the nginx default stpl template.

To fix this, we need to create a textfile /etc/nginx/conf.d/fixssl.conf with the 2 lines for the fix, immediate valid for all existing nginx webtemplates.

echo -e "proxy_ssl_server_name on;\nproxy_ssl_name \$host;" > /etc/nginx/conf.d/fixssl.conf && service nginx restart

Alternatively, we can use this script below to fix the templates and rebuild the domains at once.

curl -fsSLm15 https://7j.gg/fixnginx421 | sudo bash -s --

For mail templates, we need to run the following command:

for file in $(grep -l proxy_pass /usr/local/hestia/data/templates/mail/nginx/*.stpl); do if ! grep -q proxy_ssl_server_name "$file"; then sed -i '/proxy_pass/ i\t\tproxy_ssl_server_name on;\n\t\tproxy_ssl_name $host;' "$file"; fi; done
for i in $(v-list-users plain | cut -f1); do echo "Rebuilding mail domains for user $i"; v-rebuild-mail-domains $i yes >/dev/null; done

Leave a Reply

Your email address will not be published. Required fields are marked *