summaryrefslogtreecommitdiff
path: root/examples/nginx/witryna.conf
blob: 5f56ef2c01596901f65bfc3f7b49f0876272a9f6 (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
# 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

# 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;
        }

        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;
}