When serving multiple SSL-enabled domains via reverse proxy, Nginx may return a 421 Misdirected Request error. This typically occurs due to incorrect handling of the SSL hostname (SNI) between the proxy and the upstream server.
Run this command: SSH with root access
echo -e "proxy_ssl_server_name on;\nproxy_ssl_name \$host;" > /etc/nginx/conf.d/fixssl.conf && service nginx restart
  
  This command:
proxy_ssl_server_name on;proxy_ssl_name $host;
    /etc/nginx/conf.d/fixssl.conf and restarts
      Nginx
    Why it works: The fix ensures Nginx forwards the correct hostname during TLS handshake to the upstream server—eliminating mismatched certificates and 421 errors.
Tip: Always test your Nginx config before applying:
nginx -t && nginx -s reload
The “421 Misdirected Request” error on Nginx has become more common due to changes in modern SSL handling, HTTP/2 protocol behavior, and stricter browser enforcement. Here’s a breakdown of what’s causing it and how to prevent it.
proxy_ssl_server_name on;
proxy_ssl_name $host;
    server_name, Nginx may route traffic incorrectly.proxy_ssl_server_name on;
proxy_ssl_name $host;
      when proxying HTTPS traffic.
    server_name and SSL certificate.nginx -t or nginx -T to validate configuration.Pro Tip: Log errors with error_log /var/log/nginx/error.log notice; for deeper insights into proxy issues.