Can we host subdomains in nginx on AWS Centos instance?

zsljulius asked:

Say my AWS domain name is ec2-1-2-3-4.ap-southeast-1.compute.amazonaws.com, can I create a domain name that is accessible from the outside world like app.ec2-1-2-3-4.ap-southeast-1.compute.amazonaws.com?

My app is accesible with the main domain name, but even after following the tutorial like this one,

https://hackprogramming.com/how-to-setup-subdomain-or-host-multiple-domains-using-nginx-in-linux-server/

I still cannot make the site accessible with sub domain in nginx.

My answer:


The hostname given to your instance is owned and controlled by Amazon. It is not a wildcard and therefore you cannot add subdomains to it. Its purpose is to allow you to access individual instances before (or without) you have configured names in your own domain to resolve to the instances.

You can make subdomains in domains that you control, and add the appropriate AAAA and A records to cause them to resolve to your instance.


View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.