Skip to content

Commit 6be0006

Browse files
committed
initial push
1 parent 99e27f2 commit 6be0006

File tree

118 files changed

+10561
-0
lines changed

Some content is hidden

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

118 files changed

+10561
-0
lines changed

labs/lab5/docker-compose.yml

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# NGINX Plus Proxy with tools build
2+
# NGINX webservers with ingress-demo pages
3+
# NGINX Basics, Nov 2024
4+
# Chris Akker, Shouvik Dutta, Adam Currier
5+
#
6+
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
12+
- ./nginx-plus/etc/nginx/nginx.conf:/etc/nginx/nginx.conf
13+
- ./nginx-plus/etc/nginx/conf.d:/etc/nginx/conf.d
14+
- ./nginx-plus/etc/nginx/includes:/etc/nginx/includes
15+
- ./nginx-plus/usr/share/nginx/html:/usr/share/nginx/html
16+
links:
17+
- web1:web1
18+
- web2:web2
19+
- web3:web3
20+
ports:
21+
- 80:80 # Open for HTTP
22+
- 443:443 # Open for HTTPS
23+
- 9000:9000 # Open for API / dashboard page
24+
restart: always
25+
web1:
26+
hostname: web1
27+
container_name: web1
28+
image: nginxinc/ingress-demo # Image from Docker Hub
29+
ports:
30+
- "80" # Open for HTTP
31+
- "443" # Open for HTTPS
32+
web2:
33+
hostname: web2
34+
container_name: web2
35+
image: nginxinc/ingress-demo
36+
ports:
37+
- "80"
38+
- "433"
39+
web3:
40+
hostname: web3
41+
container_name: web3
42+
image: nginxinc/ingress-demo
43+
ports:
44+
- "80"
45+
- "443"

labs/lab5/final/cafe.example.com.conf

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# cafe.example.com HTTP
2+
# NGINX Basics Workshop
3+
# Feb 2024, Chris Akker, Shouvik Dutta
4+
#
5+
server {
6+
7+
listen 80; # Listening on port 80 on all IP addresses on this machine
8+
9+
server_name cafe.example.com; # Set hostname to match in request
10+
11+
# Uncomment the zone directive below to add metrics to the Dashboard
12+
status_zone cafe-VirtualServer;
13+
14+
# access_log /var/log/nginx/cafe.example.com.log main;
15+
access_log /var/log/nginx/cafe.example.com.log main_ext; Extended Logging
16+
error_log /var/log/nginx/cafe.example.com_error.log info;
17+
18+
location / {
19+
20+
# Uncomment the status_zone directive below to add metrics to the Dashboard
21+
status_zone /;
22+
23+
# Uncomment to enable proxy headers and HTTP keep-alives
24+
include includes/proxy_headers.conf;
25+
include includes/keepalive.conf;
26+
27+
# proxy_pass http://web1; # Proxy to another server
28+
# proxy_pass http://nginx.org; # Proxy to another website
29+
proxy_pass http://nginx_cafe; # Proxy AND load balance to a list of servers
30+
}
31+
32+
}

labs/lab5/final/nginx.conf

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
2+
user nginx;
3+
worker_processes 4; # Change to use 4 workers/cores
4+
5+
error_log /var/log/nginx/error.log info;
6+
pid /var/run/nginx.pid;
7+
8+
events {
9+
worker_connections 1024;
10+
}
11+
12+
13+
http {
14+
include /etc/nginx/mime.types;
15+
default_type application/octet-stream;
16+
17+
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
18+
'$status $body_bytes_sent "$http_referer" '
19+
'"$http_user_agent" "$http_x_forwarded_for"';
20+
21+
access_log /var/log/nginx/access.log main;
22+
23+
include /etc/nginx/includes/log_formats/*.conf; # Custom Access logs formats found here
24+
25+
sendfile on;
26+
#tcp_nopush on;
27+
28+
keepalive_timeout 65;
29+
30+
#gzip on;
31+
32+
include /etc/nginx/conf.d/*.conf;
33+
}

labs/lab5/final/upstreams.conf

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# NGINX Basics, OSS Proxy to three upstream NGINX web servers
2+
# Chris Akker, Shouvik Dutta - Feb 2024
3+
#
4+
# nginx-cafe servers
5+
upstream nginx_cafe {
6+
7+
# Load Balancing Algorithms supported by NGINX
8+
# - Round Robin (Default if nothing specified)
9+
# - Least Connections
10+
# - IP Hash
11+
# - Hash (Any generic Hash)
12+
13+
# Uncomment for Least Connections algorithm
14+
least_conn;
15+
16+
# From Docker-Compose:
17+
server web1:80;
18+
server web2:80;
19+
server web3:80;
20+
21+
# Uncomment for IP Hash persistence
22+
# ip_hash;
23+
24+
# Uncomment for keepalive TCP connections to upstreams
25+
keepalive 16;
26+
27+
}

labs/lab5/media/chrome-icon.png

4.23 KB
Loading

labs/lab5/media/curl-icon.png

5.34 KB
Loading
276 KB
Loading
246 KB
Loading

labs/lab5/media/docker-icon.png

15.2 KB
Loading
101 KB
Loading
141 KB
Loading
294 KB
Loading

labs/lab5/media/lab4_dashboard.png

84.5 KB
Loading
180 KB
Loading
178 KB
Loading
75.4 KB
Loading

labs/lab5/media/lab4_nginx-web1.png

111 KB
Loading

labs/lab5/media/lab4_nginx-web2.png

109 KB
Loading

labs/lab5/media/lab4_nginx-web3.png

115 KB
Loading

labs/lab5/media/lab4_plus-diagram.png

97.3 KB
Loading
196 KB
Loading

labs/lab5/media/nginx-icon.png

9.2 KB
Loading

labs/lab5/media/nginx-logo.png

22.1 KB
Loading

labs/lab5/media/nginx-plus-icon.png

27.2 KB
Loading

labs/lab5/media/wrk-icon.jpg

7.2 KB
Loading
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
FROM nginx:mainline-alpine
2+
RUN apk add --no-cache curl ca-certificates bash bash-completion jq wget vim
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# cafe.example.com HTTP
2+
# NGINX Basics Workshop
3+
# Nov 2024, Chris Akker, Shouvik Dutta, Adam Currier
4+
#
5+
server {
6+
7+
listen 80; # Listening on port 80 on all IP addresses on this machine
8+
9+
server_name cafe.example.com; # Set hostname to match in request
10+
11+
# Uncomment the zone directive below to add metrics to the Dashboard
12+
# status_zone cafe-VirtualServer;
13+
14+
access_log /var/log/nginx/cafe.example.com.log main;
15+
error_log /var/log/nginx/cafe.example.com_error.log info;
16+
17+
location / {
18+
# Uncomment the status_zone directive below to add metrics to the Dashboard
19+
# status_zone /;
20+
21+
# Uncomment to enable HTTP keepalives and Request Headers
22+
# include includes/keepalive.conf; # Use HTTP/1.1 keepalives
23+
24+
# include includes/proxy_headers.conf; # Add Request Headers
25+
26+
# New NGINX Directive, "proxy_pass", tells NGINX to proxy traffic to another server.
27+
28+
proxy_pass http://web1; # Send requests to upstreams
29+
}
30+
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# NGINX Plus Basics, Nov 2024
2+
# Chris Akker, Shouvik Dutta, Adam Currier
3+
# dashboard.conf
4+
#
5+
server {
6+
# Conventional port for the NGINX Plus API is 8080
7+
listen 9000;
8+
access_log off; # reduce noise in access logs
9+
10+
location /api/ {
11+
# Enable in read-write mode
12+
api write=on;
13+
}
14+
# Conventional location of the NGINX Plus dashboard
15+
location = /dashboard.html {
16+
root /usr/share/nginx/html;
17+
}
18+
19+
# Redirect requests for "/" to "/dashboard.html"
20+
location / {
21+
return 301 /dashboard.html;
22+
}
23+
}
24+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
server {
2+
listen 80;
3+
server_name localhost;
4+
5+
#charset koi8-r;
6+
#access_log /var/log/nginx/host.access.log main;
7+
8+
location / {
9+
root /usr/share/nginx/html;
10+
index index.html index.htm;
11+
}
12+
13+
#error_page 404 /404.html;
14+
15+
# redirect server error pages to the static page /50x.html
16+
#
17+
error_page 500 502 503 504 /50x.html;
18+
location = /50x.html {
19+
root /usr/share/nginx/html;
20+
}
21+
22+
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
23+
#
24+
#location ~ \.php$ {
25+
# proxy_pass http://127.0.0.1;
26+
#}
27+
28+
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
29+
#
30+
#location ~ \.php$ {
31+
# root html;
32+
# fastcgi_pass 127.0.0.1:9000;
33+
# fastcgi_index index.php;
34+
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
35+
# include fastcgi_params;
36+
#}
37+
38+
# deny access to .htaccess files, if Apache's document root
39+
# concurs with nginx's one
40+
#
41+
#location ~ /\.ht {
42+
# deny all;
43+
#}
44+
}
45+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# NGINX Basics, Plus Proxy to three upstream NGINX containers
2+
# Nov 2024 - Chris Akker, Shouvik Dutta, Adam Currier
3+
#
4+
# nginx_cafe servers
5+
6+
upstream nginx_cafe { # Upstream block, the name is "nginx_cafe"
7+
8+
# Uncomment the zone directive below to add metrics to the Dashboard
9+
# zone nginx_cafe 256k;
10+
11+
# Load Balancing Algorithms supported by NGINX
12+
# - Round Robin (Default if nothing specified)
13+
# - Least Connections
14+
# - IP Hash
15+
# - Hash (Any generic Hash)
16+
17+
# Load Balancing Algorithms supported by NGINX Plus
18+
# - Least Time Last Byte / Header
19+
# - Random Two
20+
21+
# Uncomment for Least Time Last Byte algorithm
22+
# least_time last_byte;
23+
24+
# From Docker-Compose:
25+
server web1:80;
26+
server web2:80;
27+
server web3:80;
28+
29+
#U ncomment for Cookie persistence
30+
# sticky cookie srv_id expires=1m domain=.example.com path=/;
31+
32+
# Uncomment for keepalive TCP connections to upstreams
33+
# keepalive 16;
34+
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#Nginx Basics - Nov 2024
2+
#Chris Akker, Shouvik Dutta, Adam Currier
3+
#
4+
# Default is HTTP/1.0 to upstreams, keepalives is only enabled for HTTP/1.1
5+
proxy_http_version 1.1;
6+
7+
# Set the Connection header to empty
8+
proxy_set_header Connection "";
9+
10+
# Host request header field, or the server name matching a request
11+
proxy_set_header Host $host;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Extended Log Format
2+
# Nginx Basics
3+
log_format main_ext 'remote_addr="$remote_addr", '
4+
'[time_local=$time_local], '
5+
'request="$request", '
6+
'status="$status", '
7+
'http_referer="$http_referer", '
8+
'body_bytes_sent="$body_bytes_sent", '
9+
'Host="$host", '
10+
'sn="$server_name", '
11+
'request_time=$request_time, '
12+
'http_user_agent="$http_user_agent", '
13+
'http_x_forwarded_for="$http_x_forwarded_for", '
14+
'request_length="$request_length", '
15+
'upstream_address="$upstream_addr", '
16+
'upstream_status="$upstream_status", '
17+
'upstream_connect_time="$upstream_connect_time", '
18+
'upstream_header_time="$upstream_header_time", '
19+
'upstream_response_time="$upstream_response_time", '
20+
'upstream_response_length="$upstream_response_length", ';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Extended SSL Log Format
2+
# Nginx Basics
3+
log_format main_ssl 'remote_addr="$remote_addr", '
4+
'[time_local=$time_local], '
5+
'request="$request", '
6+
'status="$status", '
7+
'http_referer="$http_referer", '
8+
'body_bytes_sent="$body_bytes_sent", '
9+
'Host="$host", '
10+
'sn="$server_name", '
11+
'request_time=$request_time, '
12+
'http_user_agent="$http_user_agent", '
13+
'http_x_forwarded_for="$http_x_forwarded_for", '
14+
'request_length="$request_length", ' 'ssl_ver="$ssl_protocol", ' 'ssl_cipher="$ssl_cipher", ' 'ssl_sname="$ssl_server_name", ' 'ssl_sess_id="$ssl_session_id", ' ;
15+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#Nginx Basics - Nov 2024
2+
#Chris Akker, Shouvik Dutta, Adam Currier
3+
#
4+
## Set Headers to the proxied servers ##
5+
6+
# client address in binary, value’s length is always 4 bytes for IPv4 addresses or 16 bytes for IPv6 addresses
7+
proxy_set_header X-Real-IP $remote_addr;
8+
9+
# X-Forwarded-For client request header field with the $remote_addr variable appended to it
10+
11+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
12+
13+
# request scheme, “http” or “https”
14+
proxy_set_header X-Forwarded-Proto $scheme;
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
user nginx;
2+
worker_processes 1;
3+
4+
error_log /var/log/nginx/error.log info;
5+
pid /var/run/nginx.pid;
6+
7+
events {
8+
worker_connections 1024;
9+
}
10+
11+
12+
http {
13+
include /etc/nginx/mime.types;
14+
default_type application/octet-stream;
15+
16+
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
17+
'$status $body_bytes_sent "$http_referer" '
18+
'"$http_user_agent" "$http_x_forwarded_for"';
19+
20+
access_log /var/log/nginx/access.log main;
21+
22+
include /etc/nginx/includes/log_formats/*.conf; # Custom Access logs formats found here
23+
24+
sendfile on;
25+
#tcp_nopush on;
26+
27+
keepalive_timeout 65;
28+
29+
#gzip on;
30+
31+
include /etc/nginx/conf.d/*.conf;
32+
}

labs/lab5/nginx-plus/usr/share/nginx/html/dashboard.html

+1,929
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)