summaryrefslogtreecommitdiff
path: root/examples/nginx/witryna.conf
blob: 0b92e52daf4611b66f226edaf50f6d7237f6edeb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# witryna.conf — Nginx reverse proxy configuration for Witryna
#
# Two server blocks:
# 1. Public site — serves the built static assets
# 2. Webhook endpoint — proxies deploy triggers to Witryna
#
# TLS is not configured here — use certbot or similar to add certificates:
#   sudo certbot --nginx -d my-site.example.com -d witryna.example.com

# Rate limiting: 10 requests per minute per source IP for webhook endpoints.
# Place this directive at the http {} level (outside server blocks) or in a
# separate file included from nginx.conf.
limit_req_zone $binary_remote_addr zone=witryna_webhooks:10m rate=10r/m;

# Public site — serves your built static files
server {
    listen 80;
    server_name my-site.example.com;

    root /var/lib/witryna/builds/my-site/current;
    index index.html;

    location / {
        try_files $uri $uri/ =404;
    }

    # Security headers
    add_header X-Frame-Options "DENY" always;
    add_header X-Content-Type-Options "nosniff" always;
    add_header Referrer-Policy "strict-origin-when-cross-origin" always;
}

# Webhook endpoint — reverse proxy to Witryna
server {
    listen 80;
    server_name witryna.example.com;

    # Only allow POST requests
    location / {
        limit_except POST {
            deny all;
        }

        limit_req zone=witryna_webhooks burst=5 nodelay;
        limit_req_status 429;

        proxy_pass http://127.0.0.1:8080;
        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;
    }

    # Security headers
    add_header X-Content-Type-Options "nosniff" always;
}