If someone access https://(Server IP), it throws SSL error and if they proceed, nginx gives my site's content that supposed to be only shown in my domain.
I also noticed this topic which is my issue:
but what i want is redirect my server's IP to my domain, no matter if protocol's HTTP or HTTPS.
Let's Encrypt only issues domain validated certificates. You cannot obtain a Let's Encrypt certificate for an IP.
You will be better off to simply refuse traffic that lacks a valid hostname in the host header. Regardless of how you choose to handle it, there is no Let's Encrypt solution to be had.
Redirecting HTTP is trivial.
But in order to redirect HTTPS, you must first establish an HTTPS connection.
That creates a "catch-22" situation: You would still need a cert that covers the IP in order to redirect those requests away to a name.
In short: https://{to.an.IP.address}/ is passé; No one should still be doing that in 2023.
[Haven't you heard that "Certificates are FREE now!"?]