0

What should I use for subdomain redirection? I want to create

webmail.mywebsite.com and then redirect it to gmail.com

I try to do that with nginx

server {
  server_name webmail.mywebsite.com 
  301 https://www.gmail.com
}

But nothing happens when I try to open webmail.mywebsite.com

So I get idea that maybe I should use Route53 if so what do you think what record should I put ?

Tim
  • 31,888
  • 7
  • 52
  • 78
Maw321
  • 1

1 Answers1

2

Route53 can't return redirects, it's DNS system. You need to us Nginx.

Your problem seems to be the Nginx config file is incorrect. I've copied and pasted a working Nginx config I have and changed the domains for you

server {
  listen 80;
  server_name webmail.mywebsite.com;
  return 301 https://www.gmail.com;
}

Your config appears to simply be missing is the word "return" in front of the 301.

If you want to redirect https then that's a little more work, as you need a certificate and such. You can find examples online.

Tim
  • 31,888
  • 7
  • 52
  • 78
  • Hi Tim I try to do that but I get error on my website "DNS_PROBE_FINISHED_NXDOMAIN" . I alrady have SSL installed – Maw321 Sep 15 '20 at 09:17
  • Maybe I should create record in Route53 for webmail.mywebsite.com and point IP address to my website and then maybe Nginx will be able to redirect it ?What do you think ? – Maw321 Sep 15 '20 at 09:42
  • My best guess is you haven't configured DNS for your website properly. Before you set up the 301 redirect get a basic index.html working. This will involve an A record in Route53. – Tim Sep 15 '20 at 18:02