LoginSignup
8
10

More than 5 years have passed since last update.

Nginxでサブドメインを使う場合のRoute53の設定

Posted at

環境

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で追加します。
image.png

HTMLファイルの配置

以下に、HTMLを区別がつくように配置します。
/var/www/html/sub1
/var/www/html/sample

確認

http://sample.com
http://sub1.sample.com

以上となります。

8
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
10