Skip to content

Allow including custom nginx conf files #178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions doc/ADVANCED_NGINX.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## Advanced Nginx Configuration

If you are a more advanced user, you might be itching for extra Nginx customizability.

NPM has the ability to include different custom configuration snippets in different places.

You can add your custom configuration snippet files at `/data/nginx/custom` as follow:

`/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

Every file is optional.
5 changes: 5 additions & 0 deletions rootfs/etc/nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,15 @@ http {
include /data/nginx/redirection_host/*.conf;
include /data/nginx/dead_host/*.conf;
include /data/nginx/temp/*.conf;

# Custom
include /data/nginx/custom/http[.]conf;
}

stream {
# Files generated by NPM
include /data/nginx/stream/*.conf;
}

# Custom
include /data/nginx/custom/root[.]conf;
2 changes: 2 additions & 0 deletions src/backend/templates/proxy_host.conf
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,7 @@ server {
}
{% endif %}

# Custom
include /data/nginx/custom/server_proxy[.]conf;
}
{% endif %}
2 changes: 2 additions & 0 deletions src/backend/templates/redirection_host.conf
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@ server {
}
{% endif %}

# Custom
include /data/nginx/custom/server_redirect[.]conf;
}
{% endif %}
8 changes: 8 additions & 0 deletions src/backend/templates/stream.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,20 @@
server {
listen {{ incoming_port }};
proxy_pass {{ forward_ip }}:{{ forwarding_port }};

# Custom
include /data/nginx/custom/server_stream[.]conf;
include /data/nginx/custom/server_stream_tcp[.]conf;
}
{% endif %}
{% if udp_forwarding == 1 or udp_forwarding == true %}
server {
listen {{ incoming_port }} udp;
proxy_pass {{ forward_ip }}:{{ forwarding_port }};

# Custom
include /data/nginx/custom/server_stream[.]conf;
include /data/nginx/custom/server_stream_udp[.]conf;
}
{% endif %}
{% endif %}