Configuring nginx-app.conf to find the /index.php files

390 views
Skip to first unread message

Jay-Nicolas Hackleman

unread,
Jan 22, 2018, 11:00:31 PM1/22/18
to Google App Engine
Hi,

I have recently moved over to the PHP flex environment after the standard environment dev server kept crashing. I am used to working with php on hosting providers like godaddy, bluehost, hostgator etc. Meaning that if I navigate to:
"mydomain.com/path/to/file" - then the server loads "mydomain.com/path/to/file/index.php" and everything just works. If I specify a specific file name and extension in the browser: then that specific file would load.

From what I can understand: I have to do something by providing my own "nginx-app.conf" file when deploying, but I can't figure out how to write the location object to make it work...

Here is what I have now:

location / {
 
# try to serve file directly, fallback to front controller
  try_files $uri
/app.php$is_args$args;
}


which I pulled from one of the tutorials - but it's not working as desired.

Can someone please help me out?

Jordan (Cloud Platform Support)

unread,
Jan 23, 2018, 1:34:25 PM1/23/18
to Google App Engine
You can serve static files by specifying the 'document_root' in your app.yaml, and App Engine will take care of configuring Nginx for you as described in the Serving Static Files documentation. 

- Note: Google Groups is for general product discussions and not for technical support. If you require further technical support it is recommended to post your detailed questions to Stack Overflow using the supported Cloud tags. 

Jay-Nicolas Hackleman

unread,
Jan 23, 2018, 5:12:06 PM1/23/18
to Google App Engine

Jordan (Cloud Platform Support)

unread,
Jan 24, 2018, 1:58:14 PM1/24/18
to Google App Engine
For files such as HTML, CSS, and Javascript you would use the static document root. For PHP specific scripts you can follow the documented recommendations. This configuration will fallback to serving your index.php in the case that a requested file does not exist. 

- It is good that you asked this in Stack Overflow with the proper tags. The support teams associated to the tags will be notified, and all further communications about this should occur there. 
Reply all
Reply to author
Forward
0 new messages