We are launching a PHP application into Google App Engine Flex Environment.
We have configured a custom domain. The desired behavior is that any request to http://custom.example.com will forward to https://custom.example.com
Currently, if you go to the appspot url, for example, http://project-name.appspot.com, that request does correctly forward to https://project-name.appspot.com
However, if you go to the custom domain, it does not forward to https. The application runs correctly, except that it is allowing http connection.
Google App Engine Documentation describing the available configuration files:
https://cloud.google.com/appengine/docs/flexible/php/configuring-your-app-with-app-yaml
which states:
Contents of the nginx-app.conf file will be included in the server section in the main nginx config file.
So, I am trying to create a nginx configuration that will force https. I tried this in the nginx-app.conf file:
listen 80;
server_name custom.example.com;
return 301 https://$server_name$request_uri;
But, with this config, in the browser, I get:
This page isn’t working
custom.example.com redirected you too many times.
ERR_TOO_MANY_REDIRECTS
I think I need a different nginx configuration but have not been able to find a working solution.