Google Sites @ Apex Domain

Mohammad R. Tayyebi
2 min readMay 20, 2023

It’s simple to create a website in a few minutes using Google Sites. And it’s even simpler to connect a custom domain to that by adding a CNAMErecord.

Google Sites Custom Domain Configuration

But what if we want to host our Google Sites project, on a subroute / subURL of our current website?

Nginx is always an option. With the help of porxy_pass we can directly forward traffic to/from Google Sites and surely we have to pass the Host header with the value which means, Google’s load balancer, has to pipe our request to its related server.

location /

set $google_sites "";
set $google_sites_url "organization_name/site_name";

rewrite /(.*) /$google_sites_url/$1 break;
proxy_pass https://$google_sites;
proxy_set_header Host $google_sites;

proxy_set_header User-Agent $http_user_agent;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Accept-Encoding "";
proxy_set_header Accept-Language $http_accept_language;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;


While I was testing, there wasn’t heavy traffic on my domain, but I’m not sure how AntiSpam services on the Google side will behave. Will they ban our server’s IP address? IDK. Hope that forwarding the agent, the client IP, etc has a positive effect.

Then, it’s time for a front-end JavaScript headache that causes an infinite reloading loop. Because maybe a script is there that checks the window.location compares it with Google Sites published URL. I figured out that this is due to a .js file hosted on which is a CDN for Google’s static files and it’s responsible for some lazy loading of content such as menus. Maybe some window.reload() thing running in there. So I added some simple rules that will block that file in a dirty way:

sub_filter$google_sites_url $host;
sub_filter "" "";
sub_filter_types *;
sub_filter_once off;

Maybe the better way is to sub_filter the _/atari to a subroute in our reverse proxy and write some code in Lua to find and stop that specific function.

If you have any comments on the reload problem or AntiSpam please let me know.

When it comes to web servers and web administration, Nginx can be a fast and cheap response to almost any expensive problem.