0

I have a script that is out of my control, that creates links that redirect to my server IP but with https:// on it.

This obviously create issues with the certificate. I can redirect my ip to http://domain fine but I can't make ip > https://domain work?

server {
    listen 80;
    server_name 192.168.0.1;

    return 301 $scheme://example.com$request_uri;
}

server {
    listen 443 ssl;
    server_name 192.168.0.1;

    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
    ssl_trusted_certificate /etc/letsencrypt/live/example.com/chain.pem;


    return 301 https://example.com$request_uri;
}

After that block I have another server {} listening on port 80 and 443 but with server_name using my domain if that matters.

I redacted my IP's obviously I'm using real IP's in my configuration file

4
  • What is the problem you are having? Your question doesn't say what the problem is. Commented May 20, 2019 at 7:53
  • My certificate is not valid for myip so it causes issues. But now that I'm thinking, it's not possible to do a redirect before validating the cert right? So this issue is not possible to fix on nginx, since any redirection would happen after certificate validation, and I don't have certs for my bare ip
    – Freedo
    Commented May 20, 2019 at 7:59
  • So, create a cert for your ip. Commented May 20, 2019 at 8:03
  • not possible with letsencrypt :/
    – Freedo
    Commented May 20, 2019 at 8:04

1 Answer 1

2

You can't get a TLS certificate for an IP address that browsers will recognize. You will have to fix the script which generates the inappropriate redirects. That actually is possible.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .