Skip to content

Commit aa73ec3

Browse files
committed
nginx conf
1 parent 2d1e683 commit aa73ec3

1 file changed

Lines changed: 51 additions & 0 deletions

File tree

georoadbook.nginx.conf

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
server {
2+
listen 443 ssl;
3+
http2 on;
4+
server_name georoadbook.vaguelibre.net;
5+
server_tokens off;
6+
7+
root /var/www/georoadbook/public;
8+
index index.php;
9+
10+
client_max_body_size 18M;
11+
12+
# Access and error logs
13+
access_log /var/log/nginx/georoadbook.access.log;
14+
error_log /var/log/nginx/georoadbook.error.log;
15+
16+
ssl_certificate /etc/letsencrypt/live/vaguelibre.net-0001/fullchain.pem; # managed by Certbot
17+
ssl_certificate_key /etc/letsencrypt/live/vaguelibre.net-0001/privkey.pem; # managed by Certbot
18+
19+
add_header Strict-Transport-Security "max-age=31536000";
20+
21+
# Symfony try_files: try to serve files directly, fallback to front controller index.php
22+
location / {
23+
try_files $uri /index.php$is_args$args;
24+
}
25+
26+
# Cache static assets for 1 year
27+
location ~ \.(css|js|jpg|jpeg|webp|png|gif|ico|svg|woff|woff2|ttf|eot)$ {
28+
expires 1y;
29+
gzip on;
30+
gzip_types text/css application/javascript image/svg+xml font/woff font/woff2;
31+
access_log off;
32+
log_not_found off;
33+
}
34+
35+
# Handle the main Symfony front controller (index.php)
36+
location ~ ^/index\.php(/|$) {
37+
include snippets/fastcgi-php.conf;
38+
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
39+
fastcgi_param APP_ENV prod;
40+
fastcgi_param DOCUMENT_ROOT $realpath_root;
41+
fastcgi_pass unix:/var/run/php/php8.5-fpm.sock;
42+
43+
# Prevents direct access to index.php by users
44+
internal;
45+
}
46+
47+
# Return 404 for all other PHP files to prevent arbitrary code execution
48+
location ~ \.php$ {
49+
return 404;
50+
}
51+
}

0 commit comments

Comments
 (0)