Skip to content

Instantly share code, notes, and snippets.

@sonnysasaka
sonnysasaka / nginx-app.conf
Created February 27, 2024 18:28
Allow serving static files on Google App Engine second generation PHP flex runtime - alternate
# This file is used by App Engine flex environment PHP runtime by name convention nginx-app.conf:
# https://cloud.google.com/appengine/docs/flexible/php/runtime#customize_nginx
# App Engine rewrites everything to index.php$uri, this prevents us to catch
# anything else with `location` block, so the hack is to catch it with another
# rewrite that lets us handle in our own `location ~ ^/myapp` below
# (https://github.com/GoogleCloudPlatform/buildpacks/blob/ff2ea2737a928087dcec192bf3ce103dc356ad5e/pkg/nginx/nginx.go#L93)
rewrite ^/index.php(.*)$ /myapp$1;
# If you need to handle any php file, not just index.php
@sonnysasaka
sonnysasaka / nginx-app.conf
Last active September 10, 2024 09:47
Allow serving static files on Google App Engine second generation PHP flex runtime
# This file is used by App Engine flex environment PHP runtime by name convention nginx-app.conf:
# https://cloud.google.com/appengine/docs/flexible/php/runtime#customize_nginx
# App Engine rewrites everything to index.php$uri, this prevents us to catch
# anything else with `location` block, so the hack is to catch it with another
# rewrite that lets us handle in our own `location ~ ^/myapp` below
# (https://github.com/GoogleCloudPlatform/buildpacks/blob/ff2ea2737a928087dcec192bf3ce103dc356ad5e/pkg/nginx/nginx.go#L93)
rewrite ^/index.php(.*)$ /myapp$1;
# Handle this our way first because we want to try serving a file if it matches,