File tree Expand file tree Collapse file tree 5 files changed +31
-3
lines changed
frontend/js/app/nginx/proxy Expand file tree Collapse file tree 5 files changed +31
-3
lines changed Original file line number Diff line number Diff line change 1- 'use strict' ;
2-
31const _ = require ( 'lodash' ) ;
42const fs = require ( 'fs' ) ;
53const Liquid = require ( 'liquidjs' ) ;
@@ -92,7 +90,7 @@ const internalNginx = {
9290 } )
9391 . then ( ( ) => {
9492 return combined_meta ;
95- } )
93+ } ) ;
9694 } ,
9795
9896 /**
@@ -146,13 +144,20 @@ const internalNginx = {
146144 return new Promise ( ( resolve , reject ) => {
147145 let template = null ;
148146 let filename = internalNginx . getConfigName ( host_type , host . id ) ;
147+
149148 try {
150149 template = fs . readFileSync ( __dirname + '/../templates/' + host_type + '.conf' , { encoding : 'utf8' } ) ;
151150 } catch ( err ) {
152151 reject ( new error . ConfigurationError ( err . message ) ) ;
153152 return ;
154153 }
155154
155+ // Manipulate the data a bit before sending it to the template
156+ host . use_default_location = true ;
157+ if ( typeof host . advanced_config !== 'undefined' && host . advanced_config ) {
158+ host . use_default_location = ! internalNginx . advancedConfigHasDefaultLocation ( host . advanced_config ) ;
159+ }
160+
156161 renderEngine
157162 . parseAndRender ( template , host )
158163 . then ( config_text => {
@@ -312,6 +317,14 @@ const internalNginx = {
312317 } ) ;
313318
314319 return Promise . all ( promises ) ;
320+ } ,
321+
322+ /**
323+ * @param {string } config
324+ * @returns {boolean }
325+ */
326+ advancedConfigHasDefaultLocation : function ( config ) {
327+ return ! ! config . match ( / ^ (?: .* ; ) ? \s * ?l o c a t i o n \s * ?\/ \s * ?{ / im) ;
315328 }
316329} ;
317330
Original file line number Diff line number Diff line change @@ -10,10 +10,13 @@ server {
1010
1111{{ advanced_config }}
1212
13+ {% if use_default_location %}
1314 location / {
1415{% include "_forced_ssl.conf" %}
1516{% include "_hsts.conf" %}
1617 return 404;
1718 }
19+ {% endif %}
20+
1821}
1922{% endif %}
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ server {
1616
1717{{ advanced_config }}
1818
19+ {% if use_default_location %}
1920 location / {
2021 {%- if access_list_id > 0 -%}
2122 # Access List
@@ -35,5 +36,7 @@ server {
3536 # Proxy!
3637 include conf.d/include/proxy.conf;
3738 }
39+ {% endif %}
40+
3841}
3942{% endif %}
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ server {
1212
1313{{ advanced_config }}
1414
15+ {% if use_default_location %}
1516 location / {
1617{% include "_forced_ssl.conf" %}
1718{% include "_hsts.conf" %}
@@ -22,5 +23,7 @@ server {
2223 return 301 $scheme://{{ forward_domain_name }};
2324 {% endif %}
2425 }
26+ {% endif %}
27+
2528}
2629{% endif %}
Original file line number Diff line number Diff line change 152152 <div role =" tabpanel" class =" tab-pane" id =" advanced" >
153153 <div class =" row" >
154154 <div class =" col-md-12" >
155+ <p >Nginx variables available to you are:</p >
156+ <ul class =" text-monospace" >
157+ <li >$server # Host/IP</li >
158+ <li >$port # Port Number</li >
159+ <li >$forward_scheme # http or https</li >
160+ </ul >
155161 <div class =" form-group mb-0" >
156162 <label class =" form-label" ><% - i18n (' all-hosts' , ' advanced-config' ) %> </label >
157163 <textarea name =" advanced_config" rows =" 8" class =" form-control text-monospace" placeholder =" # <%- i18n('all-hosts', 'advanced-warning') %>" ><% - advanced_config %> </textarea >
You can’t perform that action at this time.
0 commit comments