Skip to content

Commit fdf272b

Browse files
authored
Merge pull request #13 from nginxinc/akker
added .conf files
2 parents 7ad43d0 + 79ab900 commit fdf272b

File tree

3 files changed

+189
-2
lines changed

3 files changed

+189
-2
lines changed

docs/InstallationGuide.md

+103-2
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,40 @@ After the new installation of Nginx Plus, make the following configuration chang
165165

166166
- Change Nginx's http default server to port 8080. See the included `default.conf` file. After reloading nginx, the default `Welcome to Nginx` page will be located at http://localhost:8080.
167167

168-
- Use the dashboard.conf file provided. It will enable the /api endpoint, change the port to 9000, and provide access to the Plus dashboard. Place this file in the /etc/nginx/conf.d folder, and reload nginx. The Plus dashboard is now accessible at <linux-server-ip>:9000/dashboard.html. It should look similar to this:
168+
```bash
169+
cat /etc/nginx/conf.d/default.conf
170+
# Nginx K8s Loadbalancer Solution
171+
# Chris Akker, Jan 2023
172+
# Example default.conf
173+
# Change default_server to port 8080
174+
#
175+
server {
176+
listen 8080 default_server; # Changed to 8080
177+
server_name localhost;
178+
179+
#access_log /var/log/nginx/host.access.log main;
180+
181+
location / {
182+
root /usr/share/nginx/html;
183+
index index.html index.htm;
184+
}
185+
186+
#error_page 404 /404.html;
187+
188+
# redirect server error pages to the static page /50x.html
189+
#
190+
error_page 500 502 503 504 /50x.html;
191+
location = /50x.html {
192+
root /usr/share/nginx/html;
193+
}
194+
195+
### other sections removed for clarity
196+
197+
}
198+
199+
```
200+
201+
- Use the dashboard.conf file provided. It will enable the /api endpoint, change the port to 9000, and provide access to the Plus Dashboard. Place this file in the /etc/nginx/conf.d folder, and reload nginx. The Plus dashboard is now accessible at http://nginx-lb-server-ip:9000/dashboard.html. It should look similar to this:
169202

170203
![NGINX Dashboard](media/nginxlb-dashboard.png)
171204

@@ -188,7 +221,75 @@ touch /var/lib/nginx/state/nginx-lp-https.state
188221

189222
- Enable the `stream` context for Nginx, which provides TCP load balancing. See the included nginx.conf file. Notice that the stream context is no longer commented out, the new folder is included, and a new stream.log logfile is used to track requests/responses.
190223

191-
- Configure Nginx Stream for TCP loadbalancing for this Solution. Place this file in the /etc/nginx/stream folder.
224+
```bash
225+
cat /etc/nginx/nginx.conf
226+
227+
# Nginx K8s Loadbalancer Solution
228+
# Chris Akker, Jan 2023
229+
# Example nginx.conf
230+
# Enable Stream context, add /var/log/nginx/stream.log
231+
#
232+
233+
user nginx;
234+
worker_processes auto;
235+
236+
error_log /var/log/nginx/error.log notice;
237+
pid /var/run/nginx.pid;
238+
239+
events {
240+
worker_connections 1024;
241+
}
242+
243+
http {
244+
include /etc/nginx/mime.types;
245+
default_type application/octet-stream;
246+
247+
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
248+
'$status $body_bytes_sent "$http_referer" '
249+
'"$http_user_agent" "$http_x_forwarded_for"';
250+
251+
access_log /var/log/nginx/access.log main;
252+
253+
sendfile on;
254+
#tcp_nopush on;
255+
256+
keepalive_timeout 65;
257+
258+
#gzip on;
259+
260+
include /etc/nginx/conf.d/*.conf;
261+
}
262+
263+
# TCP/UDP proxy and load balancing block
264+
#
265+
stream {
266+
# Example configuration for TCP load balancing
267+
268+
#upstream stream_backend {
269+
# zone tcp_servers 64k;
270+
# server backend1.example.com:12345;
271+
# server backend2.example.com:12345;
272+
#}
273+
274+
#server {
275+
# listen 12345;
276+
# status_zone tcp_server;
277+
# proxy_pass stream_backend;
278+
279+
include /etc/nginx/stream/*.conf;
280+
281+
log_format stream '$remote_addr - $server_addr [$time_local] $status $upstream_addr $upstream_bytes_sent';
282+
283+
access_log /var/log/nginx/stream.log stream;
284+
}
285+
286+
```
287+
288+
- Configure Nginx Stream for TCP loadbalancing for this Solution.
289+
290+
`Notice that is uses Ports 80 and 443.`
291+
292+
Place this file in the /etc/nginx/stream folder.
192293

193294
```bash
194295
# NginxK8sLB Stream configuration, for L4 load balancing

docs/default.conf

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Nginx K8s Loadbalancer Solution
2+
# Chris Akker, Jan 2023
3+
# Example default.conf
4+
# Change default_server to port 8080
5+
#
6+
server {
7+
listen 8080 default_server; # Changed to 8080
8+
server_name localhost;
9+
10+
#access_log /var/log/nginx/host.access.log main;
11+
12+
location / {
13+
root /usr/share/nginx/html;
14+
index index.html index.htm;
15+
}
16+
17+
#error_page 404 /404.html;
18+
19+
# redirect server error pages to the static page /50x.html
20+
#
21+
error_page 500 502 503 504 /50x.html;
22+
location = /50x.html {
23+
root /usr/share/nginx/html;
24+
}
25+
26+
### other sections removed for clarity
27+
28+
}

docs/nginx.conf

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Nginx K8s Loadbalancer Solution
2+
# Chris Akker, Jan 2023
3+
# Example nginx.conf
4+
# Enable Stream context, add /var/log/nginx/stream.log
5+
#
6+
7+
user nginx;
8+
worker_processes auto;
9+
10+
error_log /var/log/nginx/error.log notice;
11+
pid /var/run/nginx.pid;
12+
13+
events {
14+
worker_connections 1024;
15+
}
16+
17+
http {
18+
include /etc/nginx/mime.types;
19+
default_type application/octet-stream;
20+
21+
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
22+
'$status $body_bytes_sent "$http_referer" '
23+
'"$http_user_agent" "$http_x_forwarded_for"';
24+
25+
access_log /var/log/nginx/access.log main;
26+
27+
sendfile on;
28+
#tcp_nopush on;
29+
30+
keepalive_timeout 65;
31+
32+
#gzip on;
33+
34+
include /etc/nginx/conf.d/*.conf;
35+
}
36+
37+
# TCP/UDP proxy and load balancing block
38+
#
39+
stream {
40+
# Example configuration for TCP load balancing
41+
42+
#upstream stream_backend {
43+
# zone tcp_servers 64k;
44+
# server backend1.example.com:12345;
45+
# server backend2.example.com:12345;
46+
#}
47+
48+
#server {
49+
# listen 12345;
50+
# status_zone tcp_server;
51+
# proxy_pass stream_backend;
52+
53+
include /etc/nginx/stream/*.conf;
54+
55+
log_format stream '$remote_addr - $server_addr [$time_local] $status $upstream_addr $upstream_bytes_sent';
56+
57+
access_log /var/log/nginx/stream.log stream;
58+
}

0 commit comments

Comments
 (0)