-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathnginx-config-example.conf
More file actions
70 lines (56 loc) · 2.29 KB
/
nginx-config-example.conf
File metadata and controls
70 lines (56 loc) · 2.29 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
# nginx web server configuration for esoBB
# This configuration supports both friendly URLs, with and without mod_rewrite!
server {
listen 80;
listen [::]:80;
server_name example.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name example.com;
ssl_certificate /your/certificate/chain.pem;
ssl_certificate_key /your/certificate/key.pem;
root /var/www/eso;
index index.php;
# Main location block - handles friendly URLs
location / {
# First, try to serve the file directly
# Then try as a directory
# Finally, rewrite to index.php with the path preserved (matches Apache mod_rewrite)
# This matches Apache's mod_rewrite behavior: RewriteRule ^(.*)$ index.php/$1 [QSA,L]
try_files $uri $uri/ @rewrite;
}
# Named location for rewriting friendly URLs to index.php
location @rewrite {
rewrite ^(.*)$ /index.php$1 last;
}
# PHP handler - handles index.php with path info (from friendly URLs)
# This location must come before the general PHP location block
location ~ ^/index\.php(/.*)?$ {
# Split the path: /index.php/admin/dashboard -> script: /index.php, path_info: /admin/dashboard
fastcgi_split_path_info ^(/index\.php)(/.*)$;
# Include standard FastCGI parameters
include snippets/fastcgi-php.conf;
# CRITICAL: Override SCRIPT_FILENAME to always point to index.php
# fastcgi-php.conf might set it incorrectly when PATH_INFO is present
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
# Ensure REQUEST_URI is set correctly (will be /index.php/admin/ after rewrite)
# processRequestURI() will handle stripping index.php if present
fastcgi_param REQUEST_URI $request_uri;
fastcgi_pass unix:/run/php/php8.0-fpm.sock;
}
# Handle other PHP files (like ajax.php, install files, etc.)
# This must come after the index.php location
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.0-fpm.sock;
}
# Deny access to hidden files and directories
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
}