GAE custom domain redirect from naked to www

1,711 views
Skip to first unread message

Zdenko Hrcek

unread,
Jan 15, 2017, 6:08:25 PM1/15/17
to Google App Engine
Greetings,

I am setting GAE Standard application to be served by custom domain based on docs https://cloud.google.com/appengine/docs/python/console/using-custom-domains-and-ssl
What I want to achieve is that naked domain "example.com" is automatically redirected to "www.example.com"
Currently both naked and www domains are served by GAE. I am using also SSL certificates for both naked and www subdomain.

For naked domain I have set up in DNS records four A and AAAA record types and CNAME ghs.googlehosted.com for www according instructions in docs.

I'm little stuck with redirection issue, I'm just wandering if that is even possible in current setting. I would be grateful for any advice.

Best regards,
Zdenko


Nickolas Daskalou

unread,
Jan 15, 2017, 7:41:54 PM1/15/17
to Google App Engine

Hi Zdenko,

You'll need to do this at the application level, since Google App Engine does not provide this ability out of the box.

If you're using webapp2, there should be examples of redirecting naked domains to their www counterparts.

Alternatively, a quick and dirty fix would be to point your A record to the IP address listed on this page:

http://wwwizer.com/naked-domain-redirect

If you want the SSL redirect to work though, I think you will need to subscribe to wwwizer's paid plan.

Thanks,
Nick

--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengine+unsubscribe@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/1c82649c-fa41-4c4c-a061-770e2c147ee8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Zdenko Hrcek

unread,
Jan 16, 2017, 5:03:02 AM1/16/17
to Google App Engine
Hi Nick,

Thanks for answer.
I've solved it by redirecting in webapp2 app.

Zdenko


On Monday, January 16, 2017 at 1:41:54 AM UTC+1, Nickolas Daskalou wrote:

Hi Zdenko,

You'll need to do this at the application level, since Google App Engine does not provide this ability out of the box.

If you're using webapp2, there should be examples of redirecting naked domains to their www counterparts.

Alternatively, a quick and dirty fix would be to point your A record to the IP address listed on this page:

http://wwwizer.com/naked-domain-redirect

If you want the SSL redirect to work though, I think you will need to subscribe to wwwizer's paid plan.

Thanks,
Nick

On 16/01/2017 10:08 AM, "Zdenko Hrcek" <zde...@gmail.com> wrote:
Greetings,

I am setting GAE Standard application to be served by custom domain based on docs https://cloud.google.com/appengine/docs/python/console/using-custom-domains-and-ssl
What I want to achieve is that naked domain "example.com" is automatically redirected to "www.example.com"
Currently both naked and www domains are served by GAE. I am using also SSL certificates for both naked and www subdomain.

For naked domain I have set up in DNS records four A and AAAA record types and CNAME ghs.googlehosted.com for www according instructions in docs.

I'm little stuck with redirection issue, I'm just wandering if that is even possible in current setting. I would be grateful for any advice.

Best regards,
Zdenko


--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengi...@googlegroups.com.
To post to this group, send email to google-a...@googlegroups.com.

George (Cloud Platform Support)

unread,
Jan 16, 2017, 9:42:02 AM1/16/17
to Google App Engine

There is a detailed answer covering this subject at “Enable your "naked" domain address”. General information on the subject to be found at Using Custom Domains and SSL.

Dev Mukherjee

unread,
Jan 18, 2017, 5:07:12 PM1/18/17
to google-a...@googlegroups.com
On Tue, Jan 17, 2017 at 1:42 AM, 'George (Cloud Platform Support)' via Google App Engine <google-a...@googlegroups.com> wrote:

There is a detailed answer covering this subject at “Enable your "naked" domain address”. General information on the subject to be found at Using Custom Domains and SSL.

--

I am trying to get this going as well. We followed the official instructions and added the redirect in Google Apps.

We also have the application always running SSL. So all permutations eventually redirect to www. our domain.

Everything works (HTTP naked domain redirects to www. HTTP www. redirects to HTTPS www.) except when we head to the naked domain via HTTPS, it fails to redirect to HTTPS www.

All DNS settings are as instructed.

Any clues or does this particular use case have to be handled manually? 

Nickolas Daskalou

unread,
Jan 18, 2017, 5:25:03 PM1/18/17
to Google App Engine
Hi Dev,

Does your SSL certificate support the naked domain and have you added it for your naked domain via Google's cloud console?

What happens when you do visit the naked domain over HTTPS? It would help diagnose the problem if you sent a link to your domain.

Nick


On 19 January 2017 at 09:06, Dev Mukherjee <dev...@gmail.com> wrote:
On Tue, Jan 17, 2017 at 1:42 AM, 'George (Cloud Platform Support)' via Google App Engine <google-appengine@googlegroups.com> wrote:

There is a detailed answer covering this subject at “Enable your "naked" domain address”. General information on the subject to be found at Using Custom Domains and SSL.

--

I am trying to get this going as well. We followed the official instructions and added the redirect in Google Apps.

We also have the application always running SSL. So all permutations eventually redirect to www. our domain.

Everything works (HTTP naked domain redirects to www. HTTP www. redirects to HTTPS www.) except when we head to the naked domain via HTTPS, it fails to redirect to HTTPS www.

All DNS settings are as instructed.

Any clues or does this particular use case have to be handled manually? 

--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengine+unsubscribe@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.

Dev Mukherjee

unread,
Jan 18, 2017, 7:52:46 PM1/18/17
to google-a...@googlegroups.com
On Thu, Jan 19, 2017 at 9:23 AM, Nickolas Daskalou <ni...@daskalou.com> wrote:
Hi Dev,

Does your SSL certificate support the naked domain and have you added it for your naked domain via Google's cloud console?


Don't think it does anymore as we switched to an extended validation certificate.

Would AppEngine not be accepting connections for the naked domain because the certificate?
 
What happens when you do visit the naked domain over HTTPS? It would help diagnose the problem if you sent a link to your domain.


Browser fails to establish a connection. https://twine.cloud fails and everything works well at https://www.twine.cloud

Thanks for your response Nick.

George (Cloud Platform Support)

unread,
Jan 20, 2017, 3:23:25 PM1/20/17
to Google App Engine
Hello Dev, 

You need a CNAME certificate that specifies redirecting your Root Domain to a sub-domain. Have you examined your certificate to make sure this is specified there, as desired? 

krisrak

unread,
Mar 2, 2017, 4:36:44 PM3/2/17
to Google App Engine
how did u solve, post the code

Zdenko Hrcek

unread,
Mar 2, 2017, 4:40:34 PM3/2/17
to Google App Engine
I wrote short article about redirection https://www.the-swamp.info/blog/google-app-engine-redirection-naked-domain-www/ and also set github example repository https://github.com/zdenulo/gae_redirection. Hope it helps.

Zdenko

krisrak

unread,
Mar 2, 2017, 5:00:10 PM3/2/17
to Google App Engine
will that DomainRoute work for webapp framework (not webapp2) ?

Zdenko Hrcek

unread,
Mar 2, 2017, 6:05:29 PM3/2/17
to Google App Engine
I'm not sure, I didn't use webapp framework 
Reply all
Reply to author
Forward
0 new messages