I have hosted a domain in the Nginx on my EC2 server and used this configuration:
server {
listen 80;
listen [::]:80;
server_name www.mydomain.sa mydomain.sa;
# Redirect HTTP to HTTPS with www
return 301 https://www.mydomain.sa;
}
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name mydomain.sa www.mydomain.sa;
ssl_certificate /etc/nginx/sslcert/mydomain.sa/mydomain.sa.crt;
ssl_certificate_key /etc/nginx/sslcert/mydomain.sa/mydomain.sa.key;
root /var/www/html/files/;
index index.html;
location / {
try_files $uri $uri/ =404;
}
}
When I access this domain using browsers like Chrome, Edge, Brave, etc., the domain loads without adding the https://
in the beginning, but when I search the domain in Safari, it shows this error:
I searched the internet for a solution but none of them works.