# Custom domain using AWS Cloudfront

**URL:** <https://discuss.elastic.co/t/custom-domain-using-aws-cloudfront/289621>\
**Category:** Kibana\
**Created:** [November 18, 2021, 4:19pm UTC](https://discuss.elastic.co/t/custom-domain-using-aws-cloudfront/289621 "2021-11-18T16:19:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![michael.brizic](https://avatars.discourse-cdn.com/v4/letter/m/bb73d2/32.png) [@michael.brizic](https://discuss.elastic.co/u/michael.brizic)\
**Post date:** [November 18, 2021, 4:19pm UTC](https://discuss.elastic.co/t/custom-domain-using-aws-cloudfront/289621/1 "2021-11-18T16:19:45Z")

</div>

I've read this blog post which has been helpful in getting started: [Custom Domain](https://xeraa.net/blog/2020_custom-domains-and-anonymous-access-on-elastic-cloud/)

However, due to various requirements on our end, I need to proxy our Elastic Cloud Kibana instance using AWS Route53/Cloudfront. And for this reason I'm writing this post.

I've managed to setup a distribution with my specific elastic/kibana instance URL as the origin. I also added the following two Request headers:  
kbn-xsrf: kibana  
x-found-cluster: {my-uid-kibana}

My custom domain passes all TLS verifications via curl and any browser including Qualsys tests. However, when I navigate to my custom domain I get:

```auto
{"statusCode":401,"error":"Unauthorized","message":"Unauthorized"}

```

If I navigate to my custom domain with /login appended then I get presented the login page. But once I login, it redirects back to my custom domain and returns the above 401 unauthorized error again.

I must be missing another request/response configuration to properly handle redirects after successfully logging in? I'm not sure.

Anyone able to help?

---

<div class="post-metadata">

**Author:** ![michael.brizic](https://avatars.discourse-cdn.com/v4/letter/m/bb73d2/32.png) [@michael.brizic](https://discuss.elastic.co/u/michael.brizic)\
**Post date:** [November 18, 2021, 7:19pm UTC](https://discuss.elastic.co/t/custom-domain-using-aws-cloudfront/289621/2 "2021-11-18T19:19:09Z")

</div>

UPDATE:

I managed to get around the problem regarding not being able to /login successfully.

However, I still cannot navigate to the root of my custom domain without appending /login

Also, when I try to logout, I get the following error:

```auto
{"statusCode":400,"error":"Bad Request","message":"Client should be able to process redirect response."}

```

---

<div class="post-metadata">

**Author:** ![tsullivan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tsullivan/32/31077_2.png) [@tsullivan](https://discuss.elastic.co/u/tsullivan)\
**Post date:** [December 2, 2021, 8:13pm UTC](https://discuss.elastic.co/t/custom-domain-using-aws-cloudfront/289621/3 "2021-12-02T20:13:02Z")

</div>

It sounds like the proxy is not processing redirects. Have you checked for this type of issue in the AWS documentation? Maybe this page provides some clues: [Request and response behavior for custom origins - Amazon CloudFront](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/RequestAndResponseBehaviorCustomOrigin.html#ResponseCustomRedirects)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 30, 2021, 8:13pm UTC](https://discuss.elastic.co/t/custom-domain-using-aws-cloudfront/289621/4 "2021-12-30T20:13:25Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
