This is a bit tricky but doable.After some research I found a solution that can work.Steps are as follows:
- We need a proxy server in order to perform the operations.(eg:Nginx)
- We need to make config changes to the default.conf file to proxy requests to the bucket you have your website.
This is the conf file:
server { # Listen on port 80 for all IPs associated with your machine listen 80; # Catch all other server names server_name _; # This code gets the host without www. in front and places it inside # the $host_without_www variable # If someone requests www.coolsite.com, then $host_without_www will have the value coolsite.com set $host_without_www $host; if ($host ~* www\.(.*)) { set $host_without_www $1; } location / { # This code rewrites the original request, and adds the host without www in front # E.g. if someone requests # /directory/file.ext?param=value # from the coolsite.com site the request is rewritten to # /coolsite.com/directory/file.ext?param=value set $foo 'http://sites.abcd.com'; # echo "$foo"; rewrite ^(.*)$ $foo/$host_without_www$1 break; # The rewritten request is passed to S3 proxy_pass http://sites.abcd.com; include /etc/nginx/proxy_params; } }
Now in your DNS settings change your CNAME to your proxy server address(Something like
router.abcd.com
).The proxy server will take your request and forward it to the S3 bucket where your site is hosted.- Also, you can use wwwizer.com ip address for
@
record.This will send your request to correct destination irrespective of thewww
in your URL.