Skip to content

Commit 25f374f

Browse files
committed
added steps for lab 2
1 parent 2df7454 commit 25f374f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+3242
-10
lines changed

content/nginx-one/workshops/lab2.md

Lines changed: 146 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,151 @@
11
---
2-
# We use sentence case and present imperative tone
3-
title: "Lab2"
4-
# Weights are assigned in increments of 100: determines sorting order
2+
title: "Run workshop components with Docker"
53
weight: 200
6-
# Creates a table of contents and sidebar, useful for large documents
7-
toc: false
8-
# Types have a 1:1 relationship with Hugo archetypes, so you shouldn't need to change this
4+
toc: true
95
nd-content-type: tutorial
10-
# Intended for internal catalogue and search, case sensitive:
11-
# Agent, N4Azure, NIC, NIM, NGF, NAP-DOS, NAP-WAF, NGINX One, NGINX+, Solutions, Unit
12-
nd-product: NGINX-ONE
6+
nd-product: nginx-one
137
---
148

15-
blah
9+
## Introduction
10+
11+
This guide shows you how to run a demo backend application and multiple NGINX OSS and Plus containers with Docker. The backend application runs in three `nginxinc/ingress-demo` containers, each serving a simple web page. You’ll also link each NGINX container to NGINX One Console for management and monitoring.
12+
13+
## What you’ll learn
14+
15+
By the end of this tutorial, you’ll know how to:
16+
17+
- Set up environment variables for your data plane key and license
18+
- Log in to the NGINX private registry
19+
- Generate self-signed certificates
20+
- Run Docker Compose to start 9 containers
21+
- Verify your containers in Docker and in NGINX One Console
22+
23+
## Before you begin
24+
25+
Make sure you have:
26+
27+
- An F5 Distributed Cloud (XC) account
28+
- NGINX One service enabled in your XC account
29+
- Docker and Docker Compose installed and running
30+
- An active data plane key from [Lab 1: Get started with NGINX One Console]({{< ref "nginx-one/workshops/lab1/lab1.md" >}})
31+
- A trial or paid NGINX Plus JWT license (saved as `nginx-repo.jwt`) from [MyF5](https://my.f5.com/manage/s/).
32+
- Basic Linux and NGINX know-how
33+
- Git installed and SSH key set up for GitHub access
34+
35+
---
36+
37+
## Clone the NGINX documentation repo
38+
39+
1. **Clone the repo via SSH**
40+
41+
```shell
42+
git clone git@github.com:nginx/documentation.git
43+
```
44+
45+
2. **Change to the Lab 2 directory**
46+
47+
```shell
48+
cd documentation/content/nginx-one/workshops/lab2
49+
```
50+
51+
This folder contains `docker-compose.yml` and `generate_certs.sh`.
52+
53+
---
54+
55+
## Set environment variables
56+
57+
1. **Set your data plane key**
58+
59+
```shell
60+
export TOKEN="paste-your-data-plane-key-here"
61+
echo "$TOKEN"
62+
```
63+
64+
2. **Set your NGINX Plus JWT**
65+
66+
```shell
67+
export JWT=$(cat path/to/nginx-repo.jwt)
68+
echo "$JWT"
69+
```
70+
71+
3. **Give your setup a unique name**
72+
73+
Replace `your.initials` with something that identifies you or your setup (for example, `s.jobs`)
74+
75+
```shell
76+
export NAME="your.initials"
77+
echo "$NAME"
78+
```
79+
80+
---
81+
82+
## Log in to the private registry
83+
84+
Pipe your JWT into Docker login:
85+
86+
```shell
87+
echo "$JWT" | docker login private-registry.nginx.com \
88+
--username "$JWT" --password-stdin
89+
```
90+
91+
You should see **Login Succeeded**.
92+
93+
---
94+
95+
## Generate certificates
96+
97+
Run the script to create self-signed certs:
98+
99+
```shell
100+
chmod +x generate_certs.sh
101+
./generate_certs.sh
102+
```
103+
104+
This creates `1-day.key`, `1-day.crt`, `30-day.key`, and `30-day.crt` in the `nginx-oss/etc/ssl/nginx` subfolder.
105+
106+
---
107+
108+
## Run Docker Compose
109+
110+
Start all nine containers in detached mode:
111+
112+
```shell
113+
docker compose up --force-recreate -d
114+
```
115+
116+
Wait until you see "Started" for each container.
117+
118+
---
119+
120+
## Verify containers
121+
122+
1. **Check Docker**
123+
124+
```shell
125+
docker ps | grep "$NAME"
126+
```
127+
128+
You should see 9 containers listed.
129+
130+
2. **Check NGINX One Console**
131+
132+
- Go to the **Instances** page in the NGINX One Console
133+
- Refresh and search by your `$NAME` (for example, `s.jobs`)
134+
- Confirm each instance shows a green **Online* icon.
135+
136+
If you don’t see them, double-check your `$TOKEN` or generate a new data plane key.
137+
138+
---
139+
140+
## Next steps
141+
142+
Now that your containers are up and registered, go on to explore NGINX One Console features in Lab 3.
143+
144+
[Go to Lab 3 →](../lab3/readme.md)
145+
146+
---
147+
148+
## References
149+
150+
- [NGINX One Console docs](https://docs.nginx.com/nginx-one/)
151+
- [NGINX Agent overview](https://docs.nginx.com/nginx-agent/overview/)
Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
# NGINX Plus / OSS with NGINX Agent
2+
# NGINX webservers with ingress-demo pages
3+
# NGINX One Console Instance Registration
4+
# NGINX Basics, Dec 2024
5+
# Chris Akker, Shouvik Dutta, Adam Currier
6+
#
7+
services:
8+
plus1: # Alpine NGINX Plus Web / Load Balancer
9+
environment:
10+
NGINX_AGENT_SERVER_HOST: 'agent.connect.nginx.com'
11+
NGINX_AGENT_SERVER_GRPCPORT: '443'
12+
NGINX_AGENT_TLS_ENABLE: 'true'
13+
NGINX_AGENT_SERVER_TOKEN: $TOKEN # Datakey From One Console
14+
# NGINX_AGENT_INSTANCE_GROUP: $NAME-sync-group
15+
hostname: $NAME-plus1
16+
container_name: $NAME-plus1
17+
image: private-registry.nginx.com/nginx-plus/agent:nginx-plus-r32-alpine-3.20-20240613 # CVE - From Nginx Private Registry
18+
volumes: # Sync these folders to container
19+
- ./nginx-plus/etc/nginx/nginx.conf:/etc/nginx/nginx.conf
20+
- ./nginx-plus/etc/nginx/conf.d:/etc/nginx/conf.d
21+
- ./nginx-plus/etc/nginx/includes:/etc/nginx/includes
22+
- ./nginx-plus/usr/share/nginx/html:/usr/share/nginx/html
23+
ports:
24+
- 80:80 # Open for HTTP
25+
- 443:443 # Open for HTTPS
26+
- 9000:9000 # Open for stub status page
27+
- 9113:9113 # Open for Prometheus Scraper page
28+
restart: always
29+
#
30+
plus2: # Alpine NGINX Plus Web / Load Balancer
31+
environment:
32+
NGINX_AGENT_SERVER_HOST: 'agent.connect.nginx.com'
33+
NGINX_AGENT_SERVER_GRPCPORT: '443'
34+
NGINX_AGENT_TLS_ENABLE: 'true'
35+
NGINX_AGENT_SERVER_TOKEN: $TOKEN # Datakey Fron Nginx One Console
36+
# NGINX_AGENT_INSTANCE_GROUP: $NAME-sync-group
37+
hostname: $NAME-plus2
38+
container_name: $NAME-plus2
39+
image: private-registry.nginx.com/nginx-plus/agent:nginx-plus-r31-alpine-3.19-20240522 # CVE - From Nginx Private Registry
40+
volumes: # Sync these folders to container
41+
- ./nginx-plus/etc/nginx/nginx.conf:/etc/nginx/nginx.conf
42+
- ./nginx-plus/etc/nginx/conf.d:/etc/nginx/conf.d
43+
- ./nginx-plus/etc/nginx/includes:/etc/nginx/includes
44+
- ./nginx-plus/usr/share/nginx/html:/usr/share/nginx/html
45+
ports:
46+
- '80' # Open for HTTP
47+
- '443' # Open for HTTPS
48+
- '9000' # Open for API / Dashboard page
49+
- '9113' # Open for Prometheus Scraper page
50+
restart: always
51+
#
52+
plus3: # RHEL UBI NGINX Plus Web / Load Balancer
53+
environment:
54+
NGINX_AGENT_SERVER_HOST: 'agent.connect.nginx.com'
55+
NGINX_AGENT_SERVER_GRPCPORT: '443'
56+
NGINX_AGENT_TLS_ENABLE: 'true'
57+
NGINX_AGENT_SERVER_TOKEN: $TOKEN # Datakey Fron Nginx One Console
58+
# NGINX_AGENT_INSTANCE_GROUP: $NAME-sync-group
59+
hostname: $NAME-plus3
60+
container_name: $NAME-plus3
61+
image: private-registry.nginx.com/nginx-plus/agent:nginx-plus-r31-ubi-9-20240522 # From Nginx Private Registry
62+
volumes: # Sync these folders to container
63+
- ./nginx-plus/etc/nginx/nginx.conf:/etc/nginx/nginx.conf
64+
- ./nginx-plus/etc/nginx/conf.d:/etc/nginx/conf.d
65+
- ./nginx-plus/etc/nginx/includes:/etc/nginx/includes
66+
- ./nginx-plus/usr/share/nginx/html:/usr/share/nginx/html
67+
ports:
68+
- '80' # Open for HTTP
69+
- '443' # Open for HTTPS
70+
- '9000' # Open for API / Dashboard page
71+
- '9113' # Open for Prometheus Scraper page
72+
restart: always
73+
#
74+
oss1: # Debian NGINX OSS Web / Load Balancer
75+
environment:
76+
NGINX_AGENT_SERVER_HOST: 'agent.connect.nginx.com'
77+
NGINX_AGENT_SERVER_GRPCPORT: '443'
78+
NGINX_AGENT_TLS_ENABLE: 'true'
79+
NGINX_AGENT_SERVER_TOKEN: $TOKEN # Datakey Fron Nginx One Console
80+
hostname: $NAME-oss1
81+
container_name: $NAME-oss1
82+
image: docker-registry.nginx.com/nginx/agent:mainline # From Docker Public Registry
83+
volumes: # Sync these folders to container
84+
- ./nginx-oss/etc/nginx/nginx.conf:/etc/nginx/nginx.conf
85+
- ./nginx-oss/etc/nginx/conf.d:/etc/nginx/conf.d
86+
- ./nginx-oss/etc/nginx/includes:/etc/nginx/includes
87+
- ./nginx-oss/etc/ssl/nginx:/etc/ssl/nginx
88+
- ./nginx-oss/usr/share/nginx/html:/usr/share/nginx/html
89+
ports:
90+
- '80' # Open for HTTP
91+
- '443' # Open for HTTPS
92+
- '9000' # Open for stub status page
93+
- '9113' # Open for Prometheus Scraper page
94+
restart: always
95+
#
96+
oss2: # Alpine NGINX OSS Web / Load Balancer
97+
environment:
98+
NGINX_AGENT_SERVER_HOST: 'agent.connect.nginx.com'
99+
NGINX_AGENT_SERVER_GRPCPORT: '443'
100+
NGINX_AGENT_TLS_ENABLE: 'true'
101+
NGINX_AGENT_SERVER_TOKEN: $TOKEN # Datakey Fron Nginx One Console
102+
hostname: $NAME-oss2
103+
container_name: $NAME-oss2
104+
image: docker-registry.nginx.com/nginx/agent:alpine # From Docker Public Registry
105+
volumes: # Sync these folders to container
106+
- ./nginx-oss/etc/nginx/nginx.conf:/etc/nginx/nginx.conf
107+
- ./nginx-oss/etc/nginx/conf.d:/etc/nginx/conf.d
108+
- ./nginx-oss/etc/nginx/includes:/etc/nginx/includes
109+
- ./nginx-oss/etc/ssl/nginx:/etc/ssl/nginx
110+
- ./nginx-oss/usr/share/nginx/html:/usr/share/nginx/html
111+
ports:
112+
- '80' # Open for HTTP
113+
- '443' # Open for HTTPS
114+
- '9000' # Open for stub status page
115+
- '9113' # Open for Prometheus Scraper page
116+
restart: always
117+
#
118+
oss3: # Older Alpine NGINX OSS Web / Load Balancer
119+
environment:
120+
NGINX_AGENT_SERVER_HOST: 'agent.connect.nginx.com'
121+
NGINX_AGENT_SERVER_GRPCPORT: '443'
122+
NGINX_AGENT_TLS_ENABLE: 'true'
123+
NGINX_AGENT_SERVER_TOKEN: $TOKEN # Datakey Fron Nginx One Console
124+
hostname: $NAME-oss3
125+
container_name: $NAME-oss3
126+
image: docker-registry.nginx.com/nginx/agent:1.26-alpine # From Docker Public Registry
127+
volumes: # Sync these folders to container
128+
- ./nginx-oss/etc/nginx/nginx.conf:/etc/nginx/nginx.conf
129+
- ./nginx-oss/etc/nginx/conf.d:/etc/nginx/conf.d
130+
- ./nginx-oss/etc/nginx/includes:/etc/nginx/includes
131+
- ./nginx-oss/etc/ssl/nginx:/etc/ssl/nginx
132+
- ./nginx-oss/usr/share/nginx/html:/usr/share/nginx/html
133+
ports:
134+
- '80' # Open for HTTP
135+
- '443' # Open for HTTPS
136+
- '9000' # Open for stub status page
137+
- '9113' # Open for Prometheus Scraper page
138+
restart: always
139+
#
140+
web1:
141+
hostname: $NAME-web1
142+
container_name: $NAME-web1
143+
platform: linux/amd64
144+
image: nginxinc/ingress-demo # Image from Docker Hub
145+
ports:
146+
- '80' # Open for HTTP
147+
- '443' # Open for HTTPS
148+
web2:
149+
hostname: $NAME-web2
150+
container_name: $NAME-web2
151+
platform: linux/amd64
152+
image: nginxinc/ingress-demo
153+
ports:
154+
- '80'
155+
- '433'
156+
web3:
157+
hostname: $NAME-web3
158+
container_name: $NAME-web3
159+
platform: linux/amd64
160+
image: nginxinc/ingress-demo
161+
ports:
162+
- '80'
163+
- '443'
164+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
echo "Generate 1-day cert."
2+
openssl req -x509 -nodes -days 1 -newkey rsa:2048 -keyout nginx-oss/etc/ssl/nginx/1-day.key -out nginx-oss/etc/ssl/nginx/1-day.crt -subj "/CN=$NAME-NginxOneWorkshop"
3+
echo "Generate 30-day cert."
4+
openssl req -x509 -nodes -days 30 -newkey rsa:2048 -keyout nginx-oss/etc/ssl/nginx/30-day.key -out nginx-oss/etc/ssl/nginx/30-day.crt -subj "/CN=$NAME-NginxOneWorkshop"
5+
echo "copy certs to lab5 for future labs"
6+
cp nginx-oss/etc/ssl/nginx/1-day.* ../lab5/nginx-oss/etc/ssl/nginx/
7+
cp nginx-oss/etc/ssl/nginx/30-day.* ../lab5/nginx-oss/etc/ssl/nginx/
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# cafe.example.com HTTP
2+
server {
3+
# Listening on port 80 on all IP addresses on this machine
4+
listen 80;
5+
6+
server_name cafe.example.com;
7+
8+
# status_zone cafe-VirtualServer;
9+
10+
# Server specific logging
11+
access_log /var/log/nginx/cafe.example.com.log main_ext;
12+
error_log /var/log/nginx/cafe.example.com_error.log info;
13+
14+
location / {
15+
16+
proxy_buffering off;
17+
18+
# Including best-practice headers are bonus points
19+
include includes/proxy_headers.conf;
20+
include includes/keepalive.conf;
21+
22+
# status_zone /;
23+
24+
proxy_pass http://nginx_cafe;
25+
}
26+
27+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# ngx_http_stub_status_module (Available in NGINX OSS)
2+
# provides Basic Status information http://nginx.org/en/docs/http/ngx_http_stub_status_module.html
3+
4+
server {
5+
listen 9000 ssl; # Listener for Stub Status
6+
7+
ssl_certificate /etc/ssl/nginx/30-day.crt;
8+
ssl_certificate_key /etc/ssl/nginx/30-day.key;
9+
10+
location /basic_status {
11+
stub_status;
12+
}
13+
14+
# Redirect requests for "/" to "/basic_status"
15+
location / {
16+
return 301 /basic_status;
17+
}
18+
19+
}

0 commit comments

Comments
 (0)