> For the complete documentation index, see [llms.txt](https://docs.jentis.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.jentis.com/key-features/cookie-lifetime-extender/cookie-lifetime-extender-webserver-cdn-configurations/nginx-configuration-guide.md).

# NGINX Configuration Guide

This guide walks you through setting up an Nginx web server on Ubuntu 22.04 with:

* A reverse proxy configuration where yourwebsite.com/hash points to hash.yourwebsite.com
* HTTPS support using Let’s Encrypt via Certbot

***

### **Prerequisites** <a href="#nginxconfigurationguide-prerequisites" id="nginxconfigurationguide-prerequisites"></a>

* A server running **Ubuntu 22.04**
* A registered domain name (e.g., yourwebsite.com )
* DNS A record pointing yourwebsite.com to your server’s IP

***

### **Step 1: Install Nginx** <a href="#nginxconfigurationguide-step1-installnginx" id="nginxconfigurationguide-step1-installnginx"></a>

```
sudo apt update
sudo apt install nginx -y
```

Start and enable Nginx:

```
sudo systemctl start nginx
sudo systemctl enable nginx
```

***

### **Step 2: Configure Nginx Server Block for** yourwebsite.com <a href="#nginxconfigurationguide-step2-configurenginxserverblockforyourwebsite.com" id="nginxconfigurationguide-step2-configurenginxserverblockforyourwebsite.com"></a>

Create a new config file:

```
sudo nano /etc/nginx/sites-available/yourwebsite.com
```

Paste the following content:

```
server {
    listen 80;
    server_name yourwebsite.com;

location /hash {
        proxy_pass https://hash.yourwebsite.com/;
        proxy_set_header Host hash.yourwebsite.com;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        client_max_body_size 50M;
    }

    access_log /var/log/nginx/yourwebsite.com_access.log;
    error_log /var/log/nginx/yourwebsite.com_error.log;
}
```

Enable the configuration:

```
sudo ln -s /etc/nginx/sites-available/yourwebsite.com /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
```

***

### **Step 3: (Optional) Install Certbot and Nginx Plugin** <a href="#nginxconfigurationguide-step3-optional-installcertbotandnginxplugin" id="nginxconfigurationguide-step3-optional-installcertbotandnginxplugin"></a>

```
sudo apt install certbot python3-certbot-nginx -y
```

***

### **Step 4: (Optional) Obtain SSL Certificate with Certbot** <a href="#nginxconfigurationguide-step4-optional-obtainsslcertificatewithcertbot" id="nginxconfigurationguide-step4-optional-obtainsslcertificatewithcertbot"></a>

Replace yourwebsite.com with your actual domain:

```
sudo certbot --nginx -d yourwebsite.com
```

Certbot will:

* Automatically configure HTTPS in your Nginx config
* Enable HTTP to HTTPS redirection
* Reload Nginx automatically

***

### **Step 5: Verify Setup** <a href="#nginxconfigurationguide-step5-verifysetup" id="nginxconfigurationguide-step5-verifysetup"></a>

Test the proxy by visiting:

```
https://yourwebsite.com/hash
```

It should forward the request to:

```
http://hash.yourwebsite.com/
```

***

### **Step 6: (Optional) Test Auto-Renewal** <a href="#nginxconfigurationguide-step6-optional-testauto-renewal" id="nginxconfigurationguide-step6-optional-testauto-renewal"></a>

Verify Certbot renewal service:

```
sudo systemctl list-timers | grep certbot
```

Simulate a dry run renewal:

```
sudo certbot renew --dry-run
```

***

### **Conclusion** <a href="#nginxconfigurationguide-conclusion" id="nginxconfigurationguide-conclusion"></a>

You now have:

* Nginx running on Ubuntu 22.04
* HTTPS enabled via Let’s Encrypt
* A reverse proxy from yourwebsite.com/hash to hash.yourwebsite.com

{% 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 feedback, please open a request on our [Helpdesk](https://jentis.atlassian.net/servicedesk/customer/portal/1/group/1/create/220).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.jentis.com/key-features/cookie-lifetime-extender/cookie-lifetime-extender-webserver-cdn-configurations/nginx-configuration-guide.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
