Hi,
I’m trying to move from Google App Engine Flex to Google App Engine standard.
I use Slim to provide a REST Api to my AngularJs application.
I want to serve call like
/rest/authenticate
For google App Engine Flex, I used a nginx-app.conf so that it works :
(this is a working conf for GAE Flex)
location / {
# try to serve file directly, fallback to front controller
try_files $uri /index.html$is_args$args;
}
location /rest {
# try to serve file directly, fallback to front controller
try_files $uri /rest/index.php$is_args$args;
}
location ~ \.php {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9000;
}
Now, what am I supposed to do so that Slim is working one GAE Standard ?
nginx-app.conf seems to be ignored, and it’s purpose was to rewrite
/rest/authenticate
to
/rest/index.php?authenticate
Currently, I’m getting 404 error, using
runtime: php72
entrypoint: serve public/rest/index.php
Thanks,
Thomas.
I’m trying to make a simple implementation of the mod rewrite suggestion.
I feel it’s not far from working, but I’ve a weird behavior
/public/rest/mod_rewrite.php
$path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
$_SERVER['REQUEST_URI']= substr($path, strlen("/rest"));
$_SERVER['SCRIPT_NAME']='/index.php';
require "index.php";
With the code above
$request->getUri()->getPath ();
return :
/authenticate
While I’m expecting to have the following returned
authenticate
If I use :
$_SERVER['REQUEST_URI']=$path;
$request->getUri()->getPath ();
return this
/rest/authenticate
if I use
$_SERVER['REQUEST_URI']= substr($path, strlen("/rest/")); notice the trailing '/' of the strlen
$request->getUri()->getPath ();
returns
/
and this last, I really don’t understand, I’ve dig in Slim code
$path = "/rest/authenticate";
$query = substr($path, strlen("/rest/"));
echo preg_replace_callback(
'/(?:[^a-zA-Z0-9_\-\.~!\$&\'\(\)\*\+,;=%:@\/\?]+|%(?![A-Fa-f0-9]{2}))/',
function ($match) {
return rawurlencode($match[0]);
},
$query
);
the pre_reg stuff is from filterQuery() from URI.php of slimframework.
And this returns “authenticate” as I’m expecting.
I end up updating my application to take the fact that on GAE, the REQUEST_URI is prefixed by /rest/ while on my local Apache, it’s not.