Skip to content

Commit 69084f5

Browse files
Bugfixes
1 parent f49d8d0 commit 69084f5

File tree

3 files changed

+39
-40
lines changed

3 files changed

+39
-40
lines changed

src/V3_CreateConfig.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def createconfig(declaration: ConfigDeclaration, apiversion: str, runfromautosyn
138138
"content":
139139
f"invalid rate_limit profile [{loc['rate_limit']['profile']}]"}}}
140140

141-
if d['declaration']['layer4'] is not None:
141+
if 'layer4' in d['declaration']:
142142
# Check Layer4/stream upstreams validity
143143
all_upstreams = []
144144

@@ -170,9 +170,9 @@ def createconfig(declaration: ConfigDeclaration, apiversion: str, runfromautosyn
170170
trim_blocks=True, extensions=["jinja2_base64_filters.Base64Filters"])
171171

172172
httpConf = j2_env.get_template(NcgConfig.config['templates']['httpconf']).render(
173-
declaration=d['declaration']['http'], ncgconfig=NcgConfig.config)
173+
declaration=d['declaration']['http'], ncgconfig=NcgConfig.config) if 'http' in d['declaration'] else ''
174174
streamConf = j2_env.get_template(NcgConfig.config['templates']['streamconf']).render(
175-
declaration=d['declaration']['layer4'], ncgconfig=NcgConfig.config)
175+
declaration=d['declaration']['layer4'], ncgconfig=NcgConfig.config) if 'layer' in d['declaration'] else ''
176176

177177
b64HttpConf = str(base64.urlsafe_b64encode(httpConf.encode("utf-8")), "utf-8")
178178
b64StreamConf = str(base64.urlsafe_b64encode(streamConf.encode("utf-8")), "utf-8")

src/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def delete_config(configuid: str = ""):
136136
)
137137

138138

139-
# Import OpenAPI schema
139+
# Import OpenAPI schema - beta
140140
@app.post("/v3/openapi", status_code=200, response_class=JSONResponse)
141141
def post_openapi_v3(request: Request):
142142
openAPISchema = request.json()

templates/v3/http.tmpl

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -82,46 +82,15 @@ server {
8282
{# --- Server section --- #}
8383

8484
{% for s in declaration.servers %}
85+
server {
8586
{# --- Listen section start --- #}
8687
{%- if s.listen -%}
8788
{% if s.listen.address %}
8889

89-
server {
9090
listen {{ s.listen.address }}{% if s.listen.tls and s.listen.tls.certificate %} ssl{% endif %};
9191
{% if s.listen.http2 and s.listen.http2 == True -%}http2 on;{% endif -%}
9292
{%- endif %}
9393

94-
{% if s.names -%}
95-
server_name{% for svrname in s.names %} {{ svrname }}{% endfor -%};
96-
status_zone {{ s.names[0] }};
97-
proxy_set_header Host $host;
98-
proxy_ssl_server_name on;
99-
{% endif -%}
100-
101-
{% if s.resolver -%}
102-
resolver {{ s.resolver }};
103-
{% endif -%}
104-
105-
{# --- Server NGINX App Protect WAF section start --- #}
106-
107-
{% if s.app_protect -%}
108-
{% if s.app_protect.enabled == True -%}
109-
app_protect_enable on;
110-
{% endif -%}
111-
{% if s.app_protect.policy -%}
112-
app_protect_policy_file {{ ncgconfig.nms.nap_policies_dir_pum }}/{{ s.app_protect.policy }}.tgz;
113-
{% endif -%}
114-
{% if s.app_protect.log -%}
115-
{% if s.app_protect.log.enabled == True -%}
116-
app_protect_security_log_enable on;
117-
{% if s.app_protect.log.profile_name -%}
118-
app_protect_security_log "{{ ncgconfig.nms.nap_logformats_dir_pum }}/{{ s.app_protect.log.profile_name }}.tgz" syslog:server={{ s.app_protect.log.destination }};
119-
{% endif -%}
120-
{% endif %}
121-
{% endif %}
122-
{% endif %}
123-
{# --- Server NGINX App Protect WAF section end --- #}
124-
12594
{# --- TLS section start --- #}
12695
{%- if s.listen.tls -%}
12796

@@ -177,6 +146,37 @@ server {
177146
{%- endif %}
178147
{# --- Listen section end --- #}
179148

149+
{% if s.names -%}
150+
server_name{% for svrname in s.names %} {{ svrname }}{% endfor -%};
151+
status_zone {{ s.names[0] }};
152+
proxy_set_header Host $host;
153+
proxy_ssl_server_name on;
154+
{% endif -%}
155+
156+
{% if s.resolver -%}
157+
resolver {{ s.resolver }};
158+
{% endif -%}
159+
160+
{# --- Server NGINX App Protect WAF section start --- #}
161+
162+
{% if s.app_protect -%}
163+
{% if s.app_protect.enabled == True -%}
164+
app_protect_enable on;
165+
{% endif -%}
166+
{% if s.app_protect.policy -%}
167+
app_protect_policy_file {{ ncgconfig.nms.nap_policies_dir_pum }}/{{ s.app_protect.policy }}.tgz;
168+
{% endif -%}
169+
{% if s.app_protect.log -%}
170+
{% if s.app_protect.log.enabled == True -%}
171+
app_protect_security_log_enable on;
172+
{% if s.app_protect.log.profile_name -%}
173+
app_protect_security_log "{{ ncgconfig.nms.nap_logformats_dir_pum }}/{{ s.app_protect.log.profile_name }}.tgz" syslog:server={{ s.app_protect.log.destination }};
174+
{% endif -%}
175+
{% endif %}
176+
{% endif %}
177+
{% endif %}
178+
{# --- Server NGINX App Protect WAF section end --- #}
179+
180180
{% if s.log.access %}access_log {{ s.log.access }} main;{% endif %}
181181

182182
{% if s.log.error %}error_log {{ s.log.error }};{% endif %}
@@ -239,8 +239,7 @@ server {
239239
}
240240
{% endfor %}
241241

242-
{%- if s.listen.address %}
242+
{% if s.listen.address %}
243+
{%- endif -%}
243244
}
244-
{% endif %}
245-
246-
{% endfor %}
245+
{%- endfor %}

0 commit comments

Comments
 (0)