Thursday, October 21, 2010

Use Naked Domain in Google App Engine with nginx

As we may know that Google announced App Engine will no longer support naked domains.

However, there are many people still trying to bind naked domain to the website. So am I. I migrated my website to App Engine from dedicated server a few months ago. But I really do not like the form of sub domain: www.billychow.me/

Since of that, I was seeking for the solution for several days. Finally, I found another way to achieve this feature by Reverse Proxy. So I want to share this with anyone else who has not known yet.

OK, Let’s go.

First, you need install nginx and do the following configuration:

server {
  server_name example.com;

  location / {
    proxy_pass http://yourappid.appspot.com;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  }
}

Then, change the DNS A record of your naked domain to point your proxy server and wait for its effects.

Finally, open your web browser and navigate to your domain to test.

note: You can use any other web server software which support reverse proxy as proxy server if you want. The only difference is the formation of configuration file.

0 Comments: