# Amazon CloudFront (AWS) Configuration Guide

### **Introduction** <a href="#amazoncloudfront-aws-configurationguide-introduction" id="amazoncloudfront-aws-configurationguide-introduction"></a>

To forward requests to JENTIS via CloudFront, we need to add a new custom origin to the CloudFront distribution and define a behavior for the origin.

***

### **Prerequesits** <a href="#amazoncloudfront-aws-configurationguide-prerequesits" id="amazoncloudfront-aws-configurationguide-prerequesits"></a>

* Admin access to the AWS Management Console.

***

### **Step 1: Create Origin** <a href="#amazoncloudfront-aws-configurationguide-step1-createorigin" id="amazoncloudfront-aws-configurationguide-step1-createorigin"></a>

1. Sign in to the AWS Management Console and open the CloudFront console at <https://console.aws.amazon.com/cloudfront/v4/home>.
2. Navigate to Distributions
3. Open the distribution for your website
4. Navigate to Origins
5. Click Create origin<br>

   <figure><img src="/files/XdjN8XY2e9a9sH220NNQ" alt=""><figcaption></figcaption></figure>
6. Specify the following:
   1. Origin domain: `hash of the JENTIS container as subdomain` + `.` + `website domain`, e.g. [hash.yourwebsitedomain.com](http://hash.yourwebsitedomain.com/)
   2. Protocol: HTTPS
   3. Port: 443
   4. MinimumSSL protocol: TLSv1.2
   5. Name: [hash.yourwebsitedomain.com](http://hash.yourwebsitedomain.com/) (or any other)
   6. Enable Origin Shield: No<br>

      <figure><img src="/files/PKkb6Oil8WJKb3xukra9" alt=""><figcaption></figcaption></figure>
7. Press Create Origin

***

### **Step 2: Define Behavior** <a href="#amazoncloudfront-aws-configurationguide-step2-definebehavior" id="amazoncloudfront-aws-configurationguide-step2-definebehavior"></a>

1. In your website distribution go to Behaviors;
2. Click Create behavior<br>

   <figure><img src="/files/ETHEzHDANHOLfhgYm0zv" alt=""><figcaption></figcaption></figure>
3. Specify the following:
   1. Path pattern: '/' + hash of the tracking container, e.g /hash
   2. Origin and origin groups: [hash.yourwebsitedomain.com](http://hash.yourwebsitedomain.com/) (origin from the previous step)
   3. Compress objects automatically: No
   4. Viewer protocol policy: HTTPS Only
   5. Allowed HTTP methods: GET, HEAD, OPTIONS, PUT, POST, PATCH, DELETE
   6. Cache HTTP methods: disabled
   7. Allow gRPC requests over HTTP/2: disabled
   8. Restrict viewer access: No
   9. Cache key and origin requests → Cache policy: CachingDisabled
   10. Cache key and origin requests → Origin request policy: Custom policy with:\
       Headers: None\
       Cookies: All\
       Query strings: None
   11. Cache key and origin requests → Response headers policy: None<br>

       <figure><img src="/files/v2z00FvjrybE22vV3TDE" alt=""><figcaption></figcaption></figure>
4. Press Create Behavior

***

### **Step 3: Create CloudFront Function** <a href="#amazoncloudfront-aws-configurationguide-conclusion" id="amazoncloudfront-aws-configurationguide-conclusion"></a>

A CloudFront Function is required to rewrite the request path to `/` before forwarding to JENTIS.

1. In the CloudFront console, navigate to **Functions**
2. Click **Create function**
3. Enter a name: `jentis-cle-path-rewrite`
4. Replace the default code with:

```javascript
async function handler(event) {
    var request = event.request;
    request.uri = '/';
    return request;
}
```

5. Click **Save changes**
6. Click the **Publish** tab → click **Publish function**
7. Go to your distribution → **Behaviors** → find `/hash` behavior → **Edit**
8. Under **Function associations** → **Viewer request** → select `jentis-cle-path-rewrite`
9. Click **Save changes**

***

### **Conclusion** <a href="#amazoncloudfront-aws-configurationguide-conclusion" id="amazoncloudfront-aws-configurationguide-conclusion"></a>

You have now created your new custom behaviour, and your request will be forwarded from now on.

{% hint style="danger" %}
After enabling Cookie lifetime extender, the DCP will give a proxy code that is expected to be setup on `https://domain.*/hash` however, if it is set up on `https://www.domain.*/hash` it will cause a CORS Error on the Cookie Lifetime Extender Requests.

For more details on WWW configuration follow this [guide](https://docs.jentis.com/key-features/cookie-lifetime-extender/configure-your-tracking#www-configuration-guide-optional).
{% endhint %}

***

If you have any questions or suggestions, contact us through our [Helpdesk](https://jentis.atlassian.net/servicedesk/customer/portal/1).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.jentis.com/key-features/cookie-lifetime-extender/cookie-lifetime-extender-webserver-cdn-configurations/amazon-cloudfront-aws-configuration-guide.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
