Skip to content

Commit 31aa9c9

Browse files
cmerjc21
authored andcommitted
Allow including custom nginx conf files (#178)
* Allow including custom nginx conf files Give advanced users more flexibility by allowing them to include custom config files at differents locations in the nginx configuration. `/data/nginx/custom/root.conf`: Included at the very end of nginx.conf `/data/nginx/custom/http.conf`: Included at the end of the main `http` block `/data/nginx/custom/server_proxy.conf`: Included at the end of every proxy `server` block `/data/nginx/custom/server_redirect.conf`: Included at the end of every redirection `server` block `/data/nginx/custom/server_stream.conf`: Included at the end of every stream `server` block `/data/nginx/custom/server_stream_tcp.conf`: Included at the end of every TCP stream `server` block `/data/nginx/custom/server_stream_udp.conf`: Included at the end of every UDP stream `server` block * Don't fail if file doesn't exist * Advanced Nginx settings doc
1 parent ddbfdf6 commit 31aa9c9

File tree

5 files changed

+34
-0
lines changed

5 files changed

+34
-0
lines changed

doc/ADVANCED_NGINX.md

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
## Advanced Nginx Configuration
2+
3+
If you are a more advanced user, you might be itching for extra Nginx customizability.
4+
5+
NPM has the ability to include different custom configuration snippets in different places.
6+
7+
You can add your custom configuration snippet files at `/data/nginx/custom` as follow:
8+
9+
`/data/nginx/custom/root.conf`: Included at the very end of nginx.conf
10+
`/data/nginx/custom/http.conf`: Included at the end of the main http block
11+
`/data/nginx/custom/server_proxy.conf`: Included at the end of every proxy server block
12+
`/data/nginx/custom/server_redirect.conf`: Included at the end of every redirection server block
13+
`/data/nginx/custom/server_stream.conf`: Included at the end of every stream server block
14+
`/data/nginx/custom/server_stream_tcp.conf`: Included at the end of every TCP stream server block
15+
`/data/nginx/custom/server_stream_udp.conf`: Included at the end of every UDP stream server block
16+
17+
Every file is optional.

rootfs/etc/nginx/nginx.conf

+5
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,15 @@ http {
7676
include /data/nginx/redirection_host/*.conf;
7777
include /data/nginx/dead_host/*.conf;
7878
include /data/nginx/temp/*.conf;
79+
80+
# Custom
81+
include /data/nginx/custom/http[.]conf;
7982
}
8083

8184
stream {
8285
# Files generated by NPM
8386
include /data/nginx/stream/*.conf;
8487
}
8588

89+
# Custom
90+
include /data/nginx/custom/root[.]conf;

src/backend/templates/proxy_host.conf

+2
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,7 @@ server {
4141
}
4242
{% endif %}
4343

44+
# Custom
45+
include /data/nginx/custom/server_proxy[.]conf;
4446
}
4547
{% endif %}

src/backend/templates/redirection_host.conf

+2
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,7 @@ server {
2525
}
2626
{% endif %}
2727

28+
# Custom
29+
include /data/nginx/custom/server_redirect[.]conf;
2830
}
2931
{% endif %}

src/backend/templates/stream.conf

+8
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,20 @@
77
server {
88
listen {{ incoming_port }};
99
proxy_pass {{ forward_ip }}:{{ forwarding_port }};
10+
11+
# Custom
12+
include /data/nginx/custom/server_stream[.]conf;
13+
include /data/nginx/custom/server_stream_tcp[.]conf;
1014
}
1115
{% endif %}
1216
{% if udp_forwarding == 1 or udp_forwarding == true %}
1317
server {
1418
listen {{ incoming_port }} udp;
1519
proxy_pass {{ forward_ip }}:{{ forwarding_port }};
20+
21+
# Custom
22+
include /data/nginx/custom/server_stream[.]conf;
23+
include /data/nginx/custom/server_stream_udp[.]conf;
1624
}
1725
{% endif %}
1826
{% endif %}

0 commit comments

Comments
 (0)