---
title: "Comment by sivaram on \"How we generate and renew SSL certs for arbitrary custom domains using LetsEncrypt!\" | Hashnode"
description: "How do you guys force a redirect to https for an arbitrary domain? Am stuck in it Facing too many redirects server { listen 443 ssl; ssl_certificate_by_lua_bloc"
url: "https://hashnode.com/posts/how-we-generate-and-renew-ssl-certs-for-arbitrary-custom-domains-using-letsencrypt/5c94d0771e0fb7505b9b0f59/comment/5cd039955b9d942933ceadd5"
---

[Discussion](https://hashnode.com/posts/how-we-generate-and-renew-ssl-certs-for-arbitrary-custom-domains-using-letsencrypt/5c94d0771e0fb7505b9b0f59)

Comment [How we generate and renew SSL certs for arbitrary custom domains using LetsEncrypt!](https://hashnode.com/posts/how-we-generate-and-renew-ssl-certs-for-arbitrary-custom-domains-using-letsencrypt/5c94d0771e0fb7505b9b0f59)

[sivaram](https://hashnode.com/@sivaramsi)

[May 6, 2019](https://hashnode.com/posts/how-we-generate-and-renew-ssl-certs-for-arbitrary-custom-domains-using-letsencrypt/5c94d0771e0fb7505b9b0f59/comment/5cd039955b9d942933ceadd5)

How do you guys force a redirect to https for an arbitrary domain? Am stuck in it Facing too many redirects

```
  server {
    listen 443 ssl;
    ssl_certificate_by_lua_block {
      auto_ssl:ssl_certificate()
    }

  location / {

        proxy_pass http://localhost:4444;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
        proxy_redirect off;
        #try_files $uri $uri/ /;        
    }
         location @rewrites {
         rewrite ^(.+)$ / last;
  }
    ssl_certificate /etc/letsencrypt/live/mydomain/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/mydomain/privkey.pem;
  }
  server {
    listen 80;
    location /.well-known/acme-challenge/ {
      content_by_lua_block {
        auto_ssl:challenge_server()
      }
    }
      location / {
         return 301 https://$host$request_uri; 
   }    
}
```
