summarylogtreecommitdiffstats
path: root/wutsk-calendar.nginx
blob: eae1fa30b7670d90081695e8d2a800bb47b54335 (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# This Nginx configuration snippet is for WUTSK Calendar.
# It will be installed to /etc/nginx/conf.d/wutsk-calendar.conf
#
# !! IMPORTANT !!
# You MUST edit this file after installation (or preferably, create a copy and edit that,
# then include it from your main nginx.conf or another custom .conf file if you prefer,
# though this default one will be loaded by nginx's include /etc/nginx/conf.d/*.conf;)
# to set your actual 'server_name' and SSL certificate paths.

server {
    listen 80;
    # For IPv6, uncomment the line below
    # listen [::]:80;
    server_name localhost; # For initial local testing. CHANGE THIS to your actual domain for production.

    # Redirect all HTTP traffic to HTTPS
    location / {
        return 301 https://$host$request_uri;
    }
}

server {
    listen 443 ssl http2;
    # For IPv6, uncomment the line below
    # listen [::]:443 ssl http2;
    server_name localhost; # For initial local testing. CHANGE THIS to your actual domain for production.

    # SSL Configuration
    # Default: Uses self-signed certificates generated during installation for https://localhost.
    # For production: Update server_name above, install certbot & certbot-nginx, then run 'sudo certbot --nginx'.
    # Certbot will then manage your SSL certificates and update these paths.
    ssl_certificate /etc/ssl/certs/wutsk-calendar-selfsigned/fullchain.pem;
    ssl_certificate_key /etc/ssl/certs/wutsk-calendar-selfsigned/privkey.pem;

    # Example for Let's Encrypt (Certbot will configure this automatically):
    # ssl_certificate /etc/letsencrypt/live/YOUR_DOMAIN_HERE/fullchain.pem;
    # ssl_certificate_key /etc/letsencrypt/live/YOUR_DOMAIN_HERE/privkey.pem;

    # You should also include stronger SSL parameters, e.g., from a shared snippet
    # include /etc/nginx/snippets/ssl-params.conf; # (You would need to create this)
    # Basic example:
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384';
    ssl_prefer_server_ciphers off;
    ssl_session_cache shared:SSL:10m;
    ssl_session_timeout 1d;
    ssl_session_tickets off;

    # Add HSTS header (optional, but recommended after confirming HTTPS works)
    # add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;

    # Logging - Adjust paths as needed
    access_log /var/log/nginx/wutsk-calendar.access.log combined;
    error_log  /var/log/nginx/wutsk-calendar.error.log warn;

    # Reverse Proxy to the Next.js Application
    location / {
        proxy_pass http://127.0.0.1:3000; # Assumes Next.js app runs on port 3000
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        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;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Port $server_port;
        proxy_cache_bypass $http_upgrade;
    }

    # Optional: Specific error pages
    # error_page 500 502 503 504 /50x.html;
    # location = /50x.html {
    #     root /usr/share/nginx/html;
    # }
}