GAE Flexible PHP 8.2 Runtime Bug

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/Php-8-2-Google-App-Engine-Flexible-Environment-JS-and-CSS-file/m-p/622694

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.

1 Like

Hi @R0bdiabl0 ,

Welcome to Google Cloud Community!

I tried deploying some sample App Engine Flex applications using several PHP versions and they don’t appear when viewing the instances. I’ve also tried doing the same using different languages like Node or Python but I didn’t have any issues.

I would suggest filing a bug through Google Cloud issue tracker so that our engineers could take a look at this. We don’t have a specific ETA but you can keep track of its progress once the ticket has been created.

Hope this helps.

For anyone coming here with this problem: this bug was created. Please go +1 it so it gets some love from Google.