There is a bug in Google App Engine php 8.2 runtime with the nginx.conf. It is set up with a try_files directive that sends all requests to your front end controller file such as index.php.
This is a problem because you can no longer access static assets in the document root. Trying to override the configuration file with a nginx-app.conf file and a new try_files directive doesn’t work.
This is a known issue as it’s been reported by multiple others. See:
https://www.googlecloudcommunity.com/gc/Serverless/Flexible-PHP82-nginx/m-p/620797#M1994
Here is the 8.2 runtime configuration:
server {
listen 8080 default_server;
listen [::]:8080 default_server;
server_name "";
root /workspace/public;
rewrite ^/(.*)$ /index.php$uri;
location ~ ^/index.php {
...
}
include /workspace/nginx-app.conf;
}
The include /workspace/nginx-app.conf; directive in the Google App Engine’s Nginx configuration means that the settings in your nginx-app.conf file are included into the main configuration, not replacing it.
However, in Nginx, if there are conflicting directives, the ones that are processed later will take precedence. Since your nginx-app.conf is included at the end, its directives should override the ones in the main configuration.
The problem here is the rewrite ^/(.*)$ /index.php$uri; directive in the main configuration. This directive is processed before the try_files directive in your nginx-app.conf, and it rewrites all requests to /index.php, which is likely causing the issue you’re experiencing.
Unfortunately, you can’t override this rewrite directive from your nginx-app.conf because rewrite rules are processed in the order they appear in the configuration file, and your nginx-app.conf is included after the rewrite directive.
This seems to be a limitation of the Google App Engine’s PHP 8.2 runtime. I would recommend reporting this issue to Google Cloud Support. They might be able to provide a workaround or fix the issue in a future update of the runtime.