Fix nginx config for Pancake pretty URLs and static assets
- Update pancake/third_party alias path to use correct NIXPACKS_PHP_ROOT_DIR - Add proper pretty URL handling with @pancake_fallback location - Fix SCRIPT_FILENAME to use $document_root instead of $realpath_root - Enables Apache .htaccess equivalent functionality in nginx This resolves issues where: - Static assets in pancake/third_party were returning 404 - Pretty URLs without index.php were not working correctly - Pancake application routing was broken
This commit is contained in:
@@ -82,7 +82,7 @@ http {
|
|||||||
|
|
||||||
# Static assets for pancake/third_party
|
# Static assets for pancake/third_party
|
||||||
location /pancake/third_party {
|
location /pancake/third_party {
|
||||||
alias /var/www/html/pancake/third_party;
|
alias ${NIXPACKS_PHP_ROOT_DIR}/pancake/third_party;
|
||||||
expires 1y;
|
expires 1y;
|
||||||
add_header Cache-Control "public, immutable";
|
add_header Cache-Control "public, immutable";
|
||||||
|
|
||||||
@@ -93,16 +93,22 @@ http {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# PHP application for /pancake
|
# PHP application for /pancake with pretty URLs
|
||||||
location /pancake {
|
location /pancake {
|
||||||
try_files $uri $uri/ /pancake/index.php?$query_string;
|
# First try to serve the requested file/directory, then fallback to index.php
|
||||||
|
try_files $uri $uri/ @pancake_fallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Fallback location for Pancake pretty URLs
|
||||||
|
location @pancake_fallback {
|
||||||
|
rewrite ^.*$ /pancake/index.php last;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Handle PHP files
|
# Handle PHP files
|
||||||
|
|
||||||
location ~ \.php$ {
|
location ~ \.php$ {
|
||||||
fastcgi_pass 127.0.0.1:9000;
|
fastcgi_pass 127.0.0.1:9000;
|
||||||
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
|
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||||
include $!{nginx}/conf/fastcgi_params;
|
include $!{nginx}/conf/fastcgi_params;
|
||||||
include $!{nginx}/conf/fastcgi.conf;
|
include $!{nginx}/conf/fastcgi.conf;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user