You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/nginx/deployment-guides/amazon-web-services/ec2-instances-for-nginx.md
+30-30Lines changed: 30 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,9 +13,9 @@ This guide explains how to create instances in the Amazon Elastic Compute Cloud
13
13
14
14
For NGINX Plus, you can buy a prebuilt Amazon Machine Image (AMI) from the AWS Marketplace for a faster option. You can find AMIs for various operating systems, e.g., Amazon Linux, Red Hat Enterprise Linux, and Ubuntu. For instructions, see [Installing NGINX Plus AMIs on Amazon EC2]({{< relref "/nginx/admin-guide/installing-nginx/installing-nginx-plus-amazon-web-services.md" >}}).
15
15
16
-
## Prerequisites
16
+
## Before you begin
17
17
18
-
These instructions assume you have:
18
+
To complete this guide, you will need the following prerequisites:
19
19
20
20
- An [AWS account](http://docs.aws.amazon.com/AmazonSimpleDB/latest/DeveloperGuide/AboutAWSAccounts.html).
21
21
- To follow the [Ansible instructions]({{< relref "#automate-ansible" >}}), you should have basic Linux system administration skills. This includes installing software, managing files and folders, and using the command line.
@@ -26,24 +26,24 @@ These instructions assume you have:
26
26
27
27
1. Log into the EC2 dashboard in the AWS Management Console: **[https://console.aws.amazon.com/ec2](https://console.aws.amazon.com/ec2)**.
28
28
29
-
2. In the left navigation bar, choose **Instances**. Then click the **Launch Instances** button in the top right corner.
29
+
1. In the left navigation bar, choose **Instances**. Then click the **Launch Instances** button in the top right corner.
30
30
31
-
3. On the **Launch an Instance** page, give your new instance a name in the **Name and Tags** section. This name will show in the Name column of the summary table on the EC2 Instances dashboard. This guide is using "instance-name."
31
+
1. On the **Launch an Instance** page, give your new instance a name in the **Name and Tags** section. This name will show in the Name column of the summary table on the EC2 Instances dashboard. This guide is using "instance-name."
32
32
33
-
4. In the **Application and OS Images (Amazon Machine Image)** section click the image of the Linux distribution of your choice.
33
+
1. In the **Application and OS Images (Amazon Machine Image)** section click the image of the Linux distribution of your choice.
34
34
35
35
{{< img src="/img/aws/aws-nlb-instance-choose-ami.png" alt="Screenshot of AMI section on the EC2 Launch Instance page">}}
36
36
37
-
5. In the **Instance Type** section, use the dropdown to choose an appropriate instance type. The screenshot shows the **t2.micro** instance type selected by default. This type is sufficient for demo purposes.
37
+
1. In the **Instance Type** section, use the dropdown to choose an appropriate instance type. The screenshot shows the **t2.micro** instance type selected by default. This type is sufficient for demo purposes.
38
38
39
39
{{<note >}}At the time of publication, AWS offered 750 hours of free usage each month for this instance type. This applies during your first year with an AWS account. Keep in mind, though, that several NGINX instances running all day will use the free 750 hours up quickly. For example, 6 instances will use them in just over 5 days. If you use 8 instances, you'll hit the limit in under 4 days.{{</note>}}
40
40
41
41
{{< img src="/img/aws/aws-nlb-instance-choose-type.png" alt="Screenshot of Instance Type on the EC2 Launch Instance page">}}
42
42
43
-
6. In the **Key pair (login)** section, you can select an existing key pair, or create a new one. If you click on "Create new key pair," a window will pop up allowing you to download a key pair to your specifications.
43
+
1. In the **Key pair (login)** section, you can select an existing key pair, or create a new one. If you click on "Create new key pair," a window will pop up allowing you to download a key pair to your specifications.
44
44
{{<note>}} It's best practice — and necessary in production — to create a separate key for each EC2 instance. This way, if a key is compromised, only that one instance is at risk.{{</note>}}
45
45
46
-
7. Scroll down to the **Network settings** section. You can leave the defaults for VPC, and Subnet. Under **Firewall (Security Groups)** you can either create a new security group or use an existing one. If this is your first setup, keep “Create security group” checked. Also, select “Allow HTTP traffic from the internet.” If desired, also check “Allow HTTPS traffic from the internet”.
46
+
1. Scroll down to the **Network settings** section. You can leave the defaults for VPC, and Subnet. Under **Firewall (Security Groups)** you can either create a new security group or use an existing one. If this is your first setup, keep “Create security group” checked. Also, select “Allow HTTP traffic from the internet.” If desired, also check “Allow HTTPS traffic from the internet”.
47
47
48
48
This will create the following inbound security group rules:
49
49
@@ -52,12 +52,12 @@ These instructions assume you have:
52
52
-**Protocol** – TCP
53
53
-**Port Range** – 22
54
54
-**Source** – Custom `0.0.0.0/0`
55
-
2. Accept unencrypted HTTP connections from all sources
55
+
1. Accept unencrypted HTTP connections from all sources
56
56
-**Type** – HTTP
57
57
-**Protocol** – TCP
58
58
-**Port Range** – 80
59
59
-**Source** – Custom `0.0.0.0/0`
60
-
3. Accept encrypted HTTPS connections from all soruces (optional)
60
+
1. Accept encrypted HTTPS connections from all soruces (optional)
61
61
-**Type** – HTTPS
62
62
-**Protocol** – TCP
63
63
-**Port Range** – 443
@@ -69,21 +69,21 @@ These instructions assume you have:
69
69
70
70
{{< img src="/img/aws/aws-instance-select-sg.png" alt="Screenshot of Network Settings on the EC2 Launch Instance page with the option of selecting an existing security group">}}
71
71
72
-
8. In the **Configure Storage** section, leave the defaults unchanged.
72
+
1. In the **Configure Storage** section, leave the defaults unchanged.
73
73
74
-
9. In the right-hand panel, verify the settings shown in the **Summary** are correct. If so, click the **Launch Instance** button in the lower-right corner.
74
+
1. In the right-hand panel, verify the settings shown in the **Summary** are correct. If so, click the **Launch Instance** button in the lower-right corner.
75
75
76
76
{{< img src="/img/aws/aws-instance-summary.png" alt="Screenshot of the Summary panel on the EC2 Launch Instance page with button to launch instance">}}
77
77
78
-
10. After you launch the instance, you will be redirected. The new page will show a success message confirming that your instance launched successfully. Click on the id of the new instance to be taken back to the EC2 Instances page.
78
+
1. After you launch the instance, you will be redirected. The new page will show a success message confirming that your instance launched successfully. Click on the id of the new instance to be taken back to the EC2 Instances page.
79
79
80
80
{{< img src="/img/aws/aws-instance-launch-success.png" alt="Screenshot of the Summary panel on the EC2 Launch Instance page with button to launch instance">}}
81
81
82
-
11. On the EC2 Instances page, you can see all the instances you have created so far, including your new instance. The following screenshot shows a single instance:
82
+
1. On the EC2 Instances page, you can see all the instances you have created so far, including your new instance. The following screenshot shows a single instance:
83
83
84
84
{{< img src="/img/aws/aws-generic-instance-display-first.png" alt="Screenshot of the EC2 Instances page with a single instance">}}
85
85
86
-
12. Finalize your security group rules. You only need to do this for the first instance in a set. All other instances in that set can use the same security group.
86
+
1. Finalize your security group rules. You only need to do this for the first instance in a set. All other instances in that set can use the same security group.
87
87
88
88
- In the left navigation bar, select **Security Groups**.
89
89
- Select the security group by clicking its radio button in the leftmost column of the table. A panel opens in the lower part of the window displaying details about the group.
@@ -98,17 +98,17 @@ These instructions assume you have:
98
98
99
99
{{< img src="/img/aws/aws-generic-instance-security-outbound.png" alt="Screenshot of the EC2 Security Group outbound rules page">}}
100
100
101
-
13. To install NGINX software on the instance, first [connect]({{< relref "#connect-to-an-ec2-instance" >}}) to it. Then follow the instructions in the NGINX Plus Admin Guide for [NGINX Open Source]({{< relref "/nginx/admin-guide/installing-nginx/installing-nginx-open-source#prebuilt" >}}) and [NGINX Plus]({{< relref "/nginx/admin-guide/installing-nginx/installing-nginx-plus.md" >}}).
101
+
1. To install NGINX software on the instance, first [connect]({{< relref "#connect-to-an-ec2-instance" >}}) to it. Then follow the instructions in the NGINX Plus Admin Guide for [NGINX Open Source]({{< relref "/nginx/admin-guide/installing-nginx/installing-nginx-open-source#prebuilt" >}}) and [NGINX Plus]({{< relref "/nginx/admin-guide/installing-nginx/installing-nginx-plus.md" >}}).
102
102
103
103
---
104
104
105
105
## Connect to an EC2 Instance
106
106
To install and configure NGINX Open Source or NGINX Plus on an instance, open a terminal window and connect to the instance over SSH.
107
107
108
108
1. Navigate to the **Instances** tab on the EC2 Dashboard if you are not there already.
109
-
2. Click the row for an instance to select it.
110
-
3. Click the **Connect** button above the list of instances. You will be redirected to the **Connect To Instance** page. The **SSH client** tab will be selected by default.
111
-
4. Follow the instructions on the page, which are customized to the selected instance. There is a sample `ssh` command with the name of the key file and the hostname of your instance.
109
+
1. Click the row for an instance to select it.
110
+
1. Click the **Connect** button above the list of instances. You will be redirected to the **Connect To Instance** page. The **SSH client** tab will be selected by default.
111
+
1. Follow the instructions on the page, which are customized to the selected instance. There is a sample `ssh` command with the name of the key file and the hostname of your instance.
112
112
113
113
{{< img src="/img/aws/aws-nlb-instance-connect.png" alt="Screenshot of the EC2 Instance Connect with SSH page">}}
114
114
@@ -128,17 +128,17 @@ NGINX, Inc. releases a combined Ansible role for NGINX Open Source and NGINX P
128
128
129
129
1.[Connect to the EC2 instance]({{< relref "#connect-instance" >}}).
130
130
131
-
2. Install Ansible following the [instructions](https://docs.ansible.com/ansible/latest/installation_guide/installation_distros.html) for the operating system on your EC2 instance.
131
+
1. Install Ansible following the [instructions](https://docs.ansible.com/ansible/latest/installation_guide/installation_distros.html) for the operating system on your EC2 instance.
132
132
133
-
3. Install the official Ansible role from NGINX:
133
+
1. Install the official Ansible role from NGINX:
134
134
135
135
```shell
136
136
ansible-galaxy install nginxinc.nginx
137
137
```
138
138
139
-
4. (NGINX Plus only) Copy the **nginx-repo.key** and **nginx-repo.crt** files provided by NGINX, Inc. to **~/.ssh/ngx-certs/**.
139
+
1. (NGINX Plus only) Copy the **nginx-repo.key** and **nginx-repo.crt** files provided by NGINX, Inc. to **~/.ssh/ngx-certs/**.
140
140
141
-
5. Create a file called **playbook.yml** with the following contents:
141
+
1. Create a file called **playbook.yml** with the following contents:
142
142
143
143
```none
144
144
---
@@ -148,13 +148,13 @@ NGINX, Inc. releases a combined Ansible role for NGINX Open Source and NGINX P
148
148
- role: nginxinc.nginx
149
149
```
150
150
151
-
5. Run the playbook:
151
+
1. Run the playbook:
152
152
153
153
```shell
154
154
ansible-playbook playbook.yml
155
155
```
156
156
157
-
6. Confirm that Nginx is installed by running `nginx -v`.
157
+
1. Confirm that Nginx is installed by running `nginx -v`.
158
158
159
159
160
160
## Optional: Create an NGINX Open Source AMI
@@ -163,17 +163,17 @@ To simplify installing NGINX Open Source on several instances, create an AMI fro
163
163
164
164
1. Follow the instructions in [Create Amazon EC2 Instance]({{< relref "#create-ec2-instances" >}}) and [Install NGINX software]({{< relref "#install-nginx-software" >}}).
165
165
166
-
2. Navigate to the **Instances** tab on the Amazon EC2 Dashboard.
166
+
1. Navigate to the **Instances** tab on the Amazon EC2 Dashboard.
167
167
168
-
3. Select the base instance with NGINX installed by clicking its row in the table.
168
+
1. Select the base instance with NGINX installed by clicking its row in the table.
169
169
170
-
4. Click the **Actions** button and select **Image and templates** and then **Create Image**.
170
+
1. Click the **Actions** button and select **Image and templates** and then **Create Image**.
171
171
172
172
{{< img src="/img/aws/aws-generic-create-image-menu.png" alt="Screenshot of the EC2 Create Image button menu">}}
173
173
174
-
5. On the **Create Image** page, enter the **Image name** and optionally give an **Image description**. Then click the **Create image** button. You will be returned to the Instances page with a green alert message that the image is being created.
174
+
1. On the **Create Image** page, enter the **Image name** and optionally give an **Image description**. Then click the **Create image** button. You will be returned to the Instances page with a green alert message that the image is being created.
175
175
176
-
6. To verify that the image was created, navigate to the **AMIs** tab and find the new image by the name you gave it.
176
+
1. To verify that the image was created, navigate to the **AMIs** tab and find the new image by the name you gave it.
0 commit comments