I'm trying to achieve api.com => api.myapp.com
without success.
main nginx run on aws/ec2 on docker and listen to port 80
server { listen 80; server_name myapp.com; location / { proxy_pass http://app:80/; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header Host $host; }}server { listen 80 l; server_name api.myapp.com; location / { proxy_pass http://api:80/; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header Host $host; }}
myapp.com domain configured
A Record => @(host) => 1.10.10.30(aws-ec2/ip)
A Record => api(host) => 1.10.10.30(aws-ec2/ip)
with this configuration it works fine. visiting myapp.com
resolves app
, and api.myapp.com
resolves api service.
(I hope it's ok until now, so let me know if it wrong way to do it)
the problem
Now, I want to configure api.com
with CNAME
api.myapp.com
.I went to my domain manager(godaddy) and set as:
CNAME
=>www
=>api.myapp.com
when i visit api.com
it resolves myapp.com
and not api.myapp.com
what should i do?