Skip to content

Commit 99ed138

Browse files
authored
Add Lab7 (#31)
* lab7 updates
1 parent c085711 commit 99ed138

18 files changed

+1995
-76
lines changed

labs/lab7/docker-compose.yml

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,60 @@
1-
# NGINX Plus Proxy with tools build
1+
# NGINX Plus Proxy with NGINX Agent
22
# NGINX webservers with ingress-demo pages
3-
# NGINX Basics, Nov 2024
3+
# NGINX One Console, Mar 2025
44
# Chris Akker, Shouvik Dutta, Adam Currier
55
#
66
services:
7-
nginx-plus: # NGINX Plus Web / Load Balancer
8-
hostname: nginx-plus
9-
container_name: nginx-plus
10-
image: nginx-plus:workshop # From Lab1
11-
volumes: # Sync these folders to container
7+
nginx-plus: # NGINX Plus Web / Load Balancer
8+
environment:
9+
NGINX_AGENT_SERVER_HOST: 'agent.connect.nginx.com'
10+
NGINX_AGENT_SERVER_GRPCPORT: '443'
11+
NGINX_AGENT_TLS_ENABLE: 'true'
12+
NGINX_AGENT_SERVER_TOKEN: $TOKEN # Datakey From One Console
13+
hostname: $NAME-nginx-plus
14+
container_name: $NAME-nginx-plus
15+
image: private-registry.nginx.com/nginx-plus/agent:nginx-plus-r32-debian # From Nginx Private Registry
16+
volumes: # Sync these folders to container
1217
- ./nginx-plus/etc/nginx/nginx.conf:/etc/nginx/nginx.conf
1318
- ./nginx-plus/etc/nginx/conf.d:/etc/nginx/conf.d
1419
- ./nginx-plus/etc/nginx/includes:/etc/nginx/includes
1520
- ./nginx-plus/usr/share/nginx/html:/usr/share/nginx/html
21+
- ./nginx-plus/usr/share/nginx-plus-module-prometheus:/usr/share/nginx-plus-module-prometheus
1622
ports:
1723
- 80:80 # Open for HTTP
1824
- 443:443 # Open for HTTPS
19-
- 9000:9000 # Open for stub status page
20-
- 9113:9113 # Open for Prometheus Scraper page
21-
restart: always
25+
- 9000:9000 # Open for API / Dashboard page
26+
- 9113:9113 # Open for Prometheus scraper page
27+
restart: always
28+
#
2229
web1:
23-
hostname: web1
24-
container_name: web1
30+
hostname: $NAME-web1
31+
container_name: $NAME-web1
2532
image: nginxinc/ingress-demo # Image from Docker Hub
2633
ports:
2734
- "80" # Open for HTTP
2835
- "443" # Open for HTTPS
2936
web2:
30-
hostname: web2
31-
container_name: web2
37+
hostname: $NAME-web2
38+
container_name: $NAME-web2
3239
image: nginxinc/ingress-demo
3340
ports:
3441
- "80"
3542
- "433"
3643
web3:
37-
hostname: web3
38-
container_name: web3
44+
hostname: $NAME-web3
45+
container_name: $NAME-web3
3946
image: nginxinc/ingress-demo
4047
ports:
4148
- "80"
42-
- "443"
49+
- "443"
4350
prometheus:
4451
hostname: prometheus
4552
container_name: prometheus
4653
image: prom/prometheus
4754
volumes:
4855
- ./nginx-plus/etc/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
4956
ports:
50-
- "9090:9090"
57+
- "9090:9090" # Prometheus Server Web Console
5158
restart: always
5259
depends_on:
5360
- nginx-plus
@@ -58,7 +65,7 @@ services:
5865
- grafana-storage:/var/lib/grafana
5966
image: grafana/grafana
6067
ports:
61-
- "3000:3000"
68+
- "3000:3000" # Grafana Server Web Console
6269
restart: always
6370
depends_on:
6471
- nginx-plus

labs/lab7/final/nginx.conf

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# NGINX One Console, Mar 2025
2+
# Chris Akker, Shouvik Dutta, Adam Currier
3+
# nginx.conf
4+
#
5+
user nginx;
6+
worker_processes 1;
7+
8+
error_log /var/log/nginx/error.log info;
9+
pid /var/run/nginx.pid;
10+
11+
# Uncomment to enable NGINX Java Script Module
12+
load_module modules/ngx_http_js_module.so; # Added for Prometheus
13+
14+
events {
15+
worker_connections 1024;
16+
}
17+
18+
19+
http {
20+
include /etc/nginx/mime.types;
21+
default_type application/octet-stream;
22+
23+
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
24+
'$status $body_bytes_sent "$http_referer" '
25+
'"$http_user_agent" "$http_x_forwarded_for"';
26+
27+
include /etc/nginx/includes/log_formats/*.conf; # Custom Access logs formats found here
28+
29+
access_log /var/log/nginx/access.log main;
30+
31+
sendfile on;
32+
#tcp_nopush on;
33+
34+
keepalive_timeout 65;
35+
36+
#gzip on;
37+
38+
include /etc/nginx/conf.d/*.conf;
39+
40+
# Uncomment for Prometheus scraper page output
41+
subrequest_output_buffer_size 32k; # Added for Prometheus
42+
43+
}

labs/lab7/final/prometheus.conf

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Nginx One Console
2+
# NGINX Plus Prometheus configuration, for HTTP scraper page
3+
# Chris Akker, Shouvik Dutta, Adam Currier, Mar 2025
4+
# Based on: https://www.f5.com/company/blog/nginx/how-to-visualize-nginx-plus-with-prometheus-and-grafana
5+
# prometheus.conf
6+
#
7+
# Uncomment all lines below
8+
js_import /usr/share/nginx-plus-module-prometheus/prometheus.js;
9+
10+
server {
11+
12+
listen 9113; # This is the default port for Prometheus scraper page
13+
14+
location = /metrics {
15+
js_content prometheus.metrics;
16+
}
17+
18+
location /api {
19+
api;
20+
}
21+
22+
}
229 KB
Loading
168 KB
Loading
88.5 KB
Loading
164 KB
Loading
File renamed without changes.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# NginxPlus with Agent and NJS and Prometheus modules
2+
# Nginx One Workshop - Internal F5
3+
# Chris Akker, Shouvik Dutta, Adam Currier - Mar 2025
4+
#
5+
FROM private-registry.nginx.com/nginx-plus/agent:r32
6+
COPY --from=private-registry.nginx.com/nginx-plus/modules:r32-prometheus-debian usr/ /usr/
7+
#
8+
#
9+
# Install prerequisite packages:
10+
RUN apt-get update && apt-get install -y apt-transport-https lsb-release ca-certificates curl wget gnupg2 net-tools vim tree openssl jq
11+
#
12+
# Download the apt configuration to `/etc/apt/apt.conf.d`:
13+
RUN wget -P /etc/apt/apt.conf.d https://cs.nginx.com/static/files/90pkgs-nginx
14+
#
15+
# Copy certificate files and dhparams
16+
# COPY etc/ssl /etc/ssl
17+
#
18+
# COPY /etc/nginx (Nginx configuration) directory
19+
COPY etc/nginx /etc/nginx
20+
RUN chown -R nginx:nginx /etc/nginx
21+
# # Forward request logs to Docker log collector:
22+
# && ln -sf /dev/stdout /var/log/nginx/access.log \
23+
# && ln -sf /dev/stderr /var/log/nginx/error.log \
24+
# Remove the cert/keys from the image
25+
# && rm /etc/ssl/nginx/nginx-repo.crt /etc/ssl/nginx/nginx-repo.key
26+
#
27+
# COPY /usr/share/nginx/html (Nginx files) directory
28+
COPY usr/share/nginx/html /usr/share/nginx/html
29+
RUN chown -R nginx:nginx /usr/share/nginx/html
30+
#
31+
# COPY /etc/prometheus (Prometheus files) directory
32+
COPY /etc/prometheus /etc/prometheus
33+
RUN chown -R nginx:nginx /etc/prometheus
34+
#
35+
# EXPOSE ports, HTTP 80, HTTP 8080, HTTPS 443, Nginx API / status page 9000, Prometheus Exporter page 9113
36+
EXPOSE 80 443 8080 9000 9113
37+
STOPSIGNAL SIGTERM
38+
CMD ["nginx", "-g", "daemon off;"]

labs/lab7/nginx-plus/etc/nginx/conf.d/dashboard.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# NGINX Plus Basics, Nov 2024
1+
# NGINX One Console, Nov 2024
22
# Chris Akker, Shouvik Dutta, Adam Currier
33
# dashboard.conf
44
#

0 commit comments

Comments
 (0)