I'm having an issue with my domain name routing setup. I can get "example.com" to resolve correctly from the browser but, I cannot get "www.example.com" to resolve. I have read the docs for my related tech and it all seems to be set up correctly (well I still need to set up HTTPS / TLS but this will come after I can get www.example.com to resolve).
I have an AWS EC2 instance (Ubuntu 16.04.3 LTS) with an elastic IP address associated with it. I also have a domain name on GoDaddy.
My web stack uses Nginx to serve a JS frontend framework and reverse proxying to a Django API.
In AWS console / Route53 I have the following:
On my server I have the following server block for my Nginx config
server {
listen 80;
server_name example.com www.example.com;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/myproject/frontend/dist;
}
location /api/ {
include proxy_params;
proxy_pass http://unix:/home/myproject/backend/webapp/webapp.sock;
}
location / {
root /home/myproject/frontend/dist;
try_files $uri $uri/ /home/myproject/frontend/dist/index.html;
}
}
I'm sure I'm doing something dumb but, I cannot seem to figure it out. Appreciate any guidance.
Route 53 sometimes has a hard time with this, and will only use the first entry found for different A records with the same destination IP.
Instead of creating an additional A record pointing www.example.com to your server's IP(#4), try creating a CNAME record for www.example.com pointing to example.com.