# Nginx + apache + ssl = 421 misdirected request

**URL:** <https://forum.hestiacp.com/t/nginx-apache-ssl-421-misdirected-request/19502>\
**Category:** Web\
**Created:** [July 12, 2025, 12:24pm UTC](https://forum.hestiacp.com/t/nginx-apache-ssl-421-misdirected-request/19502 "2025-07-12T12:24:48Z")\
**Posts on this page:** 20\
**Page:** 3

<div class="post-metadata">

**Author:** ![drlucasmendes](https://forum.hestiacp.com/user_avatar/forum.hestiacp.com/drlucasmendes/32/1694_2.png) [@drlucasmendes](https://forum.hestiacp.com/u/drlucasmendes)\
**Post date:** [July 15, 2025, 2:58am UTC](https://forum.hestiacp.com/t/nginx-apache-ssl-421-misdirected-request/19502/41 "2025-07-15T02:58:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Gintcho](https://forum.hestiacp.com/user_avatar/forum.hestiacp.com/gintcho/32/10135_2.png) [@Gintcho](https://forum.hestiacp.com/u/Gintcho)\
**Post date:** [July 15, 2025, 6:13pm UTC](https://forum.hestiacp.com/t/nginx-apache-ssl-421-misdirected-request/19502/42 "2025-07-15T18:13:22Z")

</div>

Merci beaucoup!  
Ça marche parfait!

---

<div class="post-metadata">

**Author:** ![tasior22](https://forum.hestiacp.com/letter_avatar_proxy/v4/letter/t/b5a626/32.png) [@tasior22](https://forum.hestiacp.com/u/tasior22)\
**Post date:** [July 17, 2025, 6:59am UTC](https://forum.hestiacp.com/t/nginx-apache-ssl-421-misdirected-request/19502/43 "2025-07-17T06:59:01Z")

</div>

# 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.

---

<div class="post-metadata">

**Author:** ![nu01](https://forum.hestiacp.com/user_avatar/forum.hestiacp.com/nu01/32/7639_2.png) [@nu01](https://forum.hestiacp.com/u/nu01)\
**Post date:** [July 17, 2025, 7:04am UTC](https://forum.hestiacp.com/t/nginx-apache-ssl-421-misdirected-request/19502/44 "2025-07-17T07:04:08Z")

</div>

Already resolved here: [Nginx + apache + ssl = 421 misdirected request - #42 by Gintcho](https://forum.hestiacp.com/t/nginx-apache-ssl-421-misdirected-request/19502/42)  
[Nginx + apache + ssl = 421 misdirected request - #16 by sahsanu](https://forum.hestiacp.com/t/nginx-apache-ssl-421-misdirected-request/19502/16)

Suggestion, kindly check the forum prior to raising queries.

@eris @sahsanu kindly merge with the 421 post.

---

<div class="post-metadata">

**Author:** ![BashRoot](https://forum.hestiacp.com/letter_avatar_proxy/v4/letter/b/34f0e0/32.png) [@BashRoot](https://forum.hestiacp.com/u/BashRoot)\
**Post date:** [July 17, 2025, 10:19am UTC](https://forum.hestiacp.com/t/nginx-apache-ssl-421-misdirected-request/19502/45 "2025-07-17T10:19:36Z")

</div>

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

Open the terminal  
Enter the command

```auto
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

```auto
systemctl restart nginx
systemctl restart apache2

```

---

<div class="post-metadata">

**Author:** ![BrandCom](https://forum.hestiacp.com/user_avatar/forum.hestiacp.com/brandcom/32/5657_2.png) [@BrandCom](https://forum.hestiacp.com/u/BrandCom)\
**Post date:** [July 17, 2025, 10:45am UTC](https://forum.hestiacp.com/t/nginx-apache-ssl-421-misdirected-request/19502/46 "2025-07-17T10:45:18Z")

</div>

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 --`

---

<div class="post-metadata">

**Author:** ![exider](https://forum.hestiacp.com/letter_avatar_proxy/v4/letter/e/ebca7d/32.png) [@exider](https://forum.hestiacp.com/u/exider)\
**Post date:** [July 17, 2025, 11:21am UTC](https://forum.hestiacp.com/t/nginx-apache-ssl-421-misdirected-request/19502/47 "2025-07-17T11:21:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![eris](https://forum.hestiacp.com/user_avatar/forum.hestiacp.com/eris/32/1241_2.png) [@eris](https://forum.hestiacp.com/u/eris)\
**Post date:** [July 17, 2025, 11:48am UTC](https://forum.hestiacp.com/t/nginx-apache-ssl-421-misdirected-request/19502/48 "2025-07-17T11:48:38Z")

</div>

Already done few days ago

---

<div class="post-metadata">

**Author:** ![nu01](https://forum.hestiacp.com/user_avatar/forum.hestiacp.com/nu01/32/7639_2.png) [@nu01](https://forum.hestiacp.com/u/nu01)\
**Post date:** [July 17, 2025, 11:55am UTC](https://forum.hestiacp.com/t/nginx-apache-ssl-421-misdirected-request/19502/49 "2025-07-17T11:55:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![nyckid](https://forum.hestiacp.com/letter_avatar_proxy/v4/letter/n/439d5e/32.png) [@nyckid](https://forum.hestiacp.com/u/nyckid)\
**Post date:** [July 17, 2025, 7:13pm UTC](https://forum.hestiacp.com/t/nginx-apache-ssl-421-misdirected-request/19502/50 "2025-07-17T19:13:58Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![surya](https://forum.hestiacp.com/user_avatar/forum.hestiacp.com/surya/32/7795_2.png) [@surya](https://forum.hestiacp.com/u/surya)\
**Post date:** [July 18, 2025, 5:08am UTC](https://forum.hestiacp.com/t/nginx-apache-ssl-421-misdirected-request/19502/51 "2025-07-18T05:08:48Z")

</div>

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. ❤

---

<div class="post-metadata">

**Author:** ![chandrutamilnadu](https://forum.hestiacp.com/letter_avatar_proxy/v4/letter/c/35a633/32.png) [@chandrutamilnadu](https://forum.hestiacp.com/u/chandrutamilnadu)\
**Post date:** [July 18, 2025, 5:27am UTC](https://forum.hestiacp.com/t/nginx-apache-ssl-421-misdirected-request/19502/52 "2025-07-18T05:27:04Z")

</div>

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

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

```

This fixed my issue. Thanks

---

<div class="post-metadata">

**Author:** ![eris](https://forum.hestiacp.com/user_avatar/forum.hestiacp.com/eris/32/1241_2.png) [@eris](https://forum.hestiacp.com/u/eris)\
**Post date:** [July 18, 2025, 6:04am UTC](https://forum.hestiacp.com/t/nginx-apache-ssl-421-misdirected-request/19502/53 "2025-07-18T06:04:55Z")

</div>

> [@Hestia 1.9.4-beta](https://forum.hestiacp.com/t/hestia-1-9-4-beta/19584):
>
> We are planning the release for next Monday. Download: Due to to issues with Apache2 and SSL the following release will fix the issues with the fix from @sahsanu wget https://beta-apt.hestiacp.com/beta/hestia\_1.9.4~beta\_amd64.deb dpkg -i hestia\_1.9.4~beta\_amd64.deb Change log

will fix the issue swell

---

<div class="post-metadata">

**Author:** ![PinkedPickles](https://forum.hestiacp.com/letter_avatar_proxy/v4/letter/p/b487fb/32.png) [@PinkedPickles](https://forum.hestiacp.com/u/PinkedPickles)\
**Post date:** [July 18, 2025, 8:45am UTC](https://forum.hestiacp.com/t/nginx-apache-ssl-421-misdirected-request/19502/54 "2025-07-18T08:45:22Z")

</div>

@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](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?

---

<div class="post-metadata">

**Author:** ![sahsanu](https://forum.hestiacp.com/user_avatar/forum.hestiacp.com/sahsanu/32/9318_2.png) [@sahsanu](https://forum.hestiacp.com/u/sahsanu)\
**Post date:** [July 18, 2025, 8:50am UTC](https://forum.hestiacp.com/t/nginx-apache-ssl-421-misdirected-request/19502/55 "2025-07-18T08:50:54Z")

</div>

Hi @PinkedPickles

> [@PinkedPickles](#):
>
> So what should i do?

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

Also check the services:

```t
systemctl status nginx --no-pager -l
systemctl status apache2 --no-pager -l

```

---

<div class="post-metadata">

**Author:** ![PinkedPickles](https://forum.hestiacp.com/letter_avatar_proxy/v4/letter/p/b487fb/32.png) [@PinkedPickles](https://forum.hestiacp.com/u/PinkedPickles)\
**Post date:** [July 18, 2025, 8:53am UTC](https://forum.hestiacp.com/t/nginx-apache-ssl-421-misdirected-request/19502/56 "2025-07-18T08:53:30Z")

</div>

Thanks for advice!  
i fixed this with restarting docker container

---

<div class="post-metadata">

**Author:** ![acarv](https://forum.hestiacp.com/user_avatar/forum.hestiacp.com/acarv/32/2826_2.png) [@acarv](https://forum.hestiacp.com/u/acarv)\
**Post date:** [July 18, 2025, 1:30pm UTC](https://forum.hestiacp.com/t/nginx-apache-ssl-421-misdirected-request/19502/57 "2025-07-18T13:30:28Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mediendaniel](https://forum.hestiacp.com/letter_avatar_proxy/v4/letter/m/76d3ee/32.png) [@mediendaniel](https://forum.hestiacp.com/u/mediendaniel)\
**Post date:** [July 18, 2025, 1:42pm UTC](https://forum.hestiacp.com/t/nginx-apache-ssl-421-misdirected-request/19502/58 "2025-07-18T13:42:12Z")

</div>

Thanks - fix it 🙂

---

<div class="post-metadata">

**Author:** ![chandrutamilnadu](https://forum.hestiacp.com/letter_avatar_proxy/v4/letter/c/35a633/32.png) [@chandrutamilnadu](https://forum.hestiacp.com/u/chandrutamilnadu)\
**Post date:** [July 18, 2025, 1:47pm UTC](https://forum.hestiacp.com/t/nginx-apache-ssl-421-misdirected-request/19502/59 "2025-07-18T13:47:21Z")

</div>

Thanks.. Please fix it.

---

<div class="post-metadata">

**Author:** ![Vido](https://forum.hestiacp.com/user_avatar/forum.hestiacp.com/vido/32/8695_2.png) [@Vido](https://forum.hestiacp.com/u/Vido)\
**Post date:** [July 18, 2025, 8:34pm UTC](https://forum.hestiacp.com/t/nginx-apache-ssl-421-misdirected-request/19502/60 "2025-07-18T20:34:47Z")

</div>

> [@sahsanu](#):
>
> `curl -fsSLm15 https://7j.gg/fixnginx421 | sudo bash -s --`

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

[Previous page](https://forum.hestiacp.com/t/nginx-apache-ssl-421-misdirected-request/19502.md?page=2)

[Next page](https://forum.hestiacp.com/t/nginx-apache-ssl-421-misdirected-request/19502.md?page=4)
