Nginx + apache + ssl = 421 misdirected request

You are a life savvier!!!
OMG!!!
Thank you very much.

1 Like

Merci beaucoup!
Ça marche parfait!

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.

Already resolved here: Nginx + apache + ssl = 421 misdirected request - #42 by Gintcho
Nginx + apache + ssl = 421 misdirected request - #16 by sahsanu

Suggestion, kindly check the forum prior to raising queries.

@eris @sahsanu kindly merge with the 421 post.

For those who don’t understand what to do. I even had to register)))

Open the terminal
Enter the command

for file in $(grep -l proxy_pass /usr/local/hestia/data/templates/web/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 web domains for user $i";
  v-rebuild-web-domains $i yes;
done

After Enter the command

systemctl restart nginx
systemctl restart apache2

2 Likes

Same issue with Ubuntu 24.04.2 LTS and latest HestiaCP on last system update. Solved too by curl -fsSLm15 https://7j.gg/fixnginx421 | sudo bash -s --

Thank you guys for quick solution. I’ve spend 2 hours trying fix this myself.

2 Likes

Already done few days ago

3 Likes

This one was from today, by someone else. Sahsanu did it already. :slight_smile:

Registered an account just to say THANK YOU for saving my .. bacon .. on this. The script ran cleanly and clearly explained what it was doing. Great work!

2 Likes

I would take a little time to appreciate this community who have helped me everytime my server have been broken. Thanks everyone. The script worked flawlessly and fixed the issue in one go. :heart:

2 Likes

Edit2: If you want, you could use this script to fix the templates and rebuild the domains at once.

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

This fixed my issue. Thanks

2 Likes

will fix the issue swell

2 Likes

@sahsanu @maurice
Hello!
Tried both solutions.
For “echo -e “proxy_ssl_server_name on;\nproxy_ssl_name $host;” > /etc/nginx/conf.d/fixssl.conf && service nginx restart”
i got error " Service Unavailable

The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later."

For scrypt “curl -fsSLm15 https://7j.gg/fixnginx421 | sudo bash -s --”
i got:
Fixing Nginx templates (web and mail) to avoid error 421 after updating Apache2 to version 2.4.64

There is no need to rebuild web domains
There is no need to rebuild mail domains

Done!"

So what should i do?

Hi @PinkedPickles

Check the logs /var/log/apache2/domains/YourDomain.error.log

Also check the services:

systemctl status nginx --no-pager -l
systemctl status apache2 --no-pager -l
1 Like

Thanks for advice!
i fixed this with restarting docker container

1 Like

Thank you for the fix.

One question about this issue: Is there a way to stop Apache (or any other service) from updating automatically?

I know that I can disable it for the panel at the configuration of the upates (via the GUI), but does it also disable the update of the various services?

I’m asking this because I wasn’t aware that Apache was updated (and BTW, in my case it was updated four days ago and I only had the error 421 today!), and I want to control when I update it and the rest.

Thanks - fix it :slight_smile:

Thanks.. Please fix it.

@sahsanu thanks your ROCK! I was thinking that I’v been hacked :slight_smile:

2 Likes