I have a task to provide reliable solution to redirect domain, potingin to external IP to domain with prefix.
Currently I have a VM with nginx doing:
#redirect to www
server {
listen [::]:80 reuseport default_server;
listen 0.0.0.0:80 reuseport default_server;
return 301 https://www.$host$request_uri;
}
I think I have found only that I can put redirect for each host, one by one…
Is there any way to do it serverless as template – add www.
prefix to each querying host?
2
Answers
actually I have solved it on my own. I have create a simple App Engine service that performs simple redirect:
Apart from that, there is need for a forwarding setup from global IP to App Enginge instance. This can be done in few ways thus leving link to docs: https://cloud.google.com/load-balancing/docs/https/setting-up-https-serverless
I believe this configuration below will redirect any incoming requests without prefix to the same request with the www subdomain.