環境
Amazon Linux AMI 2017.09.1 (HVM), SSD Volume Type
Nginx 1.12.1
Nginxの設定
Nginxの設定を以下のように設定しました。
上がsample.comののサブドメイン、sub1.sample.comの設定です。
/etc/nginx/conf.d/virtual.conf
server {
listen 80;
server_name sub1.sample.com;
root /var/www/html/sub1
location / {
index index.html
}
}
server {
listen 80;
server_name sample.com;
root /var/www/html/sample
location / {
index index.html
}
}
Route53の設定
AWSにログインし、Route53を開きます。
sample.comのHosted zoneを開きます。
Crate Record Setを押して、AレコードをAliasをYesで追加します。
HTMLファイルの配置
以下に、HTMLを区別がつくように配置します。
/var/www/html/sub1
/var/www/html/sample
確認
http://sample.com
http://sub1.sample.com
以上となります。