Issue:
Facing challenges with Nginx configuration for serving static files in Google Cloud Flexible Environment with PHP 8.1 runtime.
Observations:
Solution:
By substituting the default nginx.conf file with a customized version, I successfully enabled the serving of static files.
To overwrite the entire nginx.conf file, replace nginx_conf_include: nginx-app.conf with nginx_conf_override: nginx.conf, where nginx.conf is the custom configuration file. Copy and paste the existing nginx.conf file from the layers/google.php.webconfig/webconfig/ directory and modify it according to your needs.
app.yaml (sample)
runtime: php # The name of the runtime environment that is used by your app.
env: flex # Select the flexible environment.
runtime_config:
operating_system: "ubuntu18" # The version of the operating system to use.
runtime_version: "8.1" # The version of PHP to use.
document_root: public
front_controller_file: index.php
nginx_conf_override: nginx.conf # Instead of nginx_conf_include: nginx-app.conf
...
configuring nginx (sample)
server {
...
root /workspace/public;
# commented out: rewrite ^/(.*)$ /index.php$uri;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
...
# Media: images, icons, video, audio, HTC
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
expires 10m;
access_log off;
etag on;
add_header Cache-Control "public";
}
# CSS and Javascript
location ~* \.(?:css|js)$ {
expires 10m;
access_log off;
etag on;
add_header Cache-Control "public";
}
...
}
Questions:
Have others encountered the same directory layout change when attempting to upgrade to a newer PHP runtime version?
Upon uploading the customized NGINX version, I've noticed the absence of the layers/google.php.webconfig/ directory. Why is this the case, considering that my custom NGINX file is being read correctly?
Could someone provide an overview of the container structure typically built using buildpacks?
What are the potential issues associated with overwriting the nginx.conf file?
Why was the default configuration set to pass everything through index.php?
Documentation:
App Engine Flexible - PHP runtime documentation
This seems to be an issue with all versions of php. See my post here:
https://www.googlecloudcommunity.com/gc/Serverless/GAE-Flexible-PHP-8-2-Runtime-Bug/td-p/720812
Today, I just encountered this same issue moving an older app from 7.3 to 7.4.
User | Count |
---|---|
2 | |
2 | |
1 | |
1 | |
1 |