Repository navigation
Expand file tree
/
Copy pathnginx.conf.example
More file actions
91 lines (81 loc) · 3.1 KB
/
Copy pathnginx.conf.example
File metadata and controls
91 lines (81 loc) · 3.1 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# Tina4 PHP — nginx configuration example
#
# Copy this file to your nginx sites-available directory and symlink to sites-enabled:
# sudo cp nginx.conf.example /etc/nginx/sites-available/tina4
# sudo ln -s /etc/nginx/sites-available/tina4 /etc/nginx/sites-enabled/
# sudo nginx -t && sudo systemctl reload nginx
#
# Adjust server_name, root, and fastcgi_pass to match your environment.
server {
listen 80;
server_name example.com;
root /var/www/tina4;
index index.php;
# Block sensitive files and directories
location ~ /\.(env|htaccess|htpasswd|git) {
deny all;
return 404;
}
location ~ ^/(secrets|cache)/ {
deny all;
return 404;
}
location ~ ^/src/(routes|orm|services|app|templates|scss|less)/ {
deny all;
return 404;
}
# Allow static files from src/public/ (CSS, JS, images, uploads)
location /src/public/ {
try_files $uri =404;
}
# Front controller — route all non-file requests through index.php
location / {
try_files $uri $uri/ /index.php?$query_string;
}
# PHP-FPM — adjust the socket/port to match your setup
location ~ \.php$ {
fastcgi_pass unix:/run/php/php-fpm.sock;
# For TCP: fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
# Pass Authorization header (required for Bearer tokens)
fastcgi_param HTTP_AUTHORIZATION $http_authorization;
# Timeouts for long-running requests (queues, migrations)
fastcgi_read_timeout 300;
}
# Gzip compression
gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml text/javascript;
# Security headers.
# Tina4 already emits this exact set from SecurityHeadersMiddleware
# (secure-by-default), so these are belt-and-braces and optional. They are
# kept aligned with the framework's modern values: X-XSS-Protection is "0"
# (the deprecated "1; mode=block" can INTRODUCE vulnerabilities and is off by
# default in modern browsers). Relax the CSP if you serve inline scripts/CDNs.
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-XSS-Protection "0" always;
add_header Content-Security-Policy "default-src 'self'" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
add_header Permissions-Policy "camera=(), microphone=(), geolocation=()" always;
# HSTS is HTTPS-only — set it in the TLS server block below, never on plain HTTP.
}
# Uncomment below for HTTPS (production)
# server {
# listen 443 ssl http2;
# server_name example.com;
# root /var/www/tina4;
# index index.php;
#
# ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
# ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
#
# # ... same location blocks as above ...
# }
#
# # Redirect HTTP to HTTPS
# server {
# listen 80;
# server_name example.com;
# return 301 https://$host$request_uri;
# }