> For the complete documentation index, see [llms.txt](https://docs.drakodevelopment.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.drakodevelopment.net/product-docs/getting-started/nginx-setup.md).

# Nginx Setup

### Step 1: Prerequisites

* Ubuntu/Debian server with root access
* Domain pointing to server
* DrakoPaste running on port **3000 (Optional)**

***

### Step 2: Install Nginx

```bash
sudo apt update
sudo apt install nginx
sudo systemctl enable --now nginx
```

***

### Step 3: SSL Certificate (Let’s Encrypt)

```bash
sudo apt install certbot python3-certbot-nginx
sudo certbot --nginx -d your-domain.com
```

{% hint style="success" %}
**Hint:** Replace `your-domain.com` with your actual domain.
{% endhint %}

***

### Step 4: Nginx Config

Create config:

```bash
sudo nano /etc/nginx/sites-available/drakopaste
```

Basic setup:

```nginx
server {
    listen 80;
    server_name paste.example.com;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl http2;
    server_name paste.example.com;

    ssl_certificate /etc/letsencrypt/live/paste.example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/paste.example.com/privkey.pem;

    # Security headers
    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-Content-Type-Options "nosniff";
    add_header X-XSS-Protection "1; mode=block";
    add_header Referrer-Policy "strict-origin-when-cross-origin";

    # API routes
    location /api {
        proxy_pass http://localhost:3000;
        proxy_set_header Host $host;
        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;
    }

    # Static assets with caching
    location /_next/static {
        proxy_pass http://localhost:3000;
        expires 1y;
        add_header Cache-Control "public, immutable";
    }

    # Next.js assets
    location /_next {
        proxy_pass http://localhost:3000;
        proxy_set_header Host $host;
        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;
    }

    # Main application
    location / {
        proxy_pass http://localhost:3000;
        proxy_set_header Host $host;
        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;
    }
}
```

{% hint style="danger" %} <mark style="color:red;">**Important:**</mark> Make sure to change `paste.example.com` and `3000` if you are using a different port            &#x20;
{% endhint %}

Enable:

```bash
sudo ln -s /etc/nginx/sites-available/drakopaste /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx
```

***

### Step 5: Firewall

```bash
sudo ufw allow 'Nginx Full'
sudo ufw status
```

***

### Step 6: Run DrakoPaste

```bash
cd /path/to/drakopaste
npm install
npm start
```

***

### Step 7: Test

* Visit [**https://your-domain.com**](https://your-domain.com?utm_source=chatgpt.com)
* Create a paste

***


---

# 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 dynamically by asking a question.

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

```
GET https://docs.drakodevelopment.net/product-docs/getting-started/nginx-setup.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.
