Skip to content

Commit ad7a419

Browse files
zodernunknown
authored andcommitted
Add shared nginx config
1 parent fffdcaa commit ad7a419

File tree

5 files changed

+16
-5
lines changed

5 files changed

+16
-5
lines changed

docs/docs.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ It uses HSTS. This means that if you set it to `false` after it's been true, the
534534

535535
### Custom NGINX Config
536536

537-
The nginx config is generated based on the docker containers running on the same server. At this time, it is not possible to modify the majority it. However, you can modify the server and `/` location blocks for the app.
537+
The nginx config is generated based on the docker containers running on the same server. At this time, it is not possible to modify the majority it. However, you can modify the server and `/` location blocks for the app. It is also possible to add a config that is used proxy-wide, and can add additional `upstream` and `server` blocks.
538538

539539
To extend the server block for the app, save the rules to a file and add the path to your config:
540540

@@ -562,6 +562,8 @@ module.exports = {
562562
};
563563
```
564564

565+
To learn about the nginx config used proxy-wide, look at the `proxy.shared` example in the [`advanced configuration`](#advanced-configuration) docs.
566+
565567
You can view the generated config by running
566568

567569
```bash
@@ -606,6 +608,9 @@ module.exports = {
606608
httpPort: 80,
607609
// The port to listen for https connections. Default is 443.
608610
httpsPort: 443,
611+
// Add an nginx config that is used proxy-wide.
612+
// This config can add additional upstream and server blocks if needed.
613+
nginxConfig: './path/to/config',
609614
// Environment variables for nginx proxy
610615
env: {
611616
DEFAULT_HOST: 'foo.bar.com'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Default shared nginx config

src/plugins/proxy/assets/templates/start.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,7 @@ echo "Pulled jwilder/nginx-proxy and jrcs/letsencrypt-nginx-proxy-companion"
3131

3232
# This updates nginx for all vhosts
3333
NGINX_CONFIG="client_max_body_size $CLIENT_UPLOAD_LIMIT;";
34-
echo $NGINX_CONFIG > /opt/$APPNAME/config/nginx-default.conf
35-
# sudo cat <<EOT > /opt/$APPNAME/config/nginx-default.conf
36-
# client_max_body_size clientUploadLimit ;
37-
# EOT
34+
echo $NGINX_CONFIG >> /opt/$APPNAME/config/nginx-default.conf
3835

3936
sudo docker run \
4037
-d \

src/plugins/proxy/command-handlers.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,13 @@ export function reconfigShared(api) {
185185
}
186186
});
187187

188+
const sharedNginxConfig = shared.nginxConfig || api.resolvePath(__dirname, 'assets/proxy.conf');
189+
190+
list.copy('Sending nginx config', {
191+
src: sharedNginxConfig,
192+
dest: `/opt/${PROXY_CONTAINER_NAME}/nginx-default.conf`
193+
});
194+
188195
const sessions = api.getSessions(['app']);
189196

190197
return api.runTaskList(list, sessions, {

src/plugins/proxy/validate.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const schema = joi.object().keys({
2020
clientUploadLimit: joi.alternatives().try(joi.number(), joi.string()),
2121
httpPort: joi.number(),
2222
httpsPort: joi.number(),
23+
nginxConfig: joi.string(),
2324
env: joi
2425
.object()
2526
.pattern(/[\s\S]*/, [joi.string(), joi.number(), joi.boolean()]),

0 commit comments

Comments
 (0)