I'm using nginx for hosting multiple websites on a ubuntu server. Basically my setup is as follows. 

My first domain `example1.com` (SSL enabled) can be accessed from `http://example1.com` as well as from `https://example1.com`. **This working fine.** 

But my 2nd domain `example2.com`, I don't have SSL enabled - but when I type `https://example2.com` the url redirects to the first domain `https://example1.com` - **Which is wrong**

Now currently I have added this server block if someone type in the URL with `https://` it will redirect back to `http://` on the `same domain`. But this is not the right way to handle this issue. Does anyone has some better ideas? 

```
server {
  listen   443 ssl;
  server_name  example2.com www.example2.com;
  rewrite ^   http://$server_name$request_uri? permanent;
}

```