Skip to content

Commit 1bb66c1

Browse files
committed
Added template engine
1 parent b9b5cc7 commit 1bb66c1

18 files changed

+7824
-12
lines changed

backend/embed/acme.sh

Lines changed: 7497 additions & 9 deletions
Large diffs are not rendered by default.

backend/embed/main.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ package embed
22

33
import "embed"
44

5+
// AcmeSh script
6+
//go:embed acme.sh
7+
var AcmeSh string
8+
59
// APIDocFiles contain all the files used for swagger schema generation
610
//go:embed api_docs
711
var APIDocFiles embed.FS
@@ -14,6 +18,6 @@ var Assets embed.FS
1418
//go:embed migrations/*.sql
1519
var MigrationFiles embed.FS
1620

17-
// AcmeSh script
18-
//go:embed acme.sh
19-
var AcmeSh string
21+
// NginxFiles hold nginx config templates
22+
//go:embed nginx
23+
var NginxFiles embed.FS

backend/embed/nginx/_assets.conf.hbs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{{#if caching_enabled}}
2+
# Asset Caching
3+
include conf.d/include/assets.conf;
4+
{{/if}}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{{#if certificate}}
2+
{{#if (equal certificate.certificate_authority_id "0")}}
3+
# Custom SSL
4+
ssl_certificate {{npm_data_dir}}/custom_ssl/npm-{{certificate.id}}/fullchain.pem;
5+
ssl_certificate_key {{npm_data_dir}}/custom_ssl/npm-{{certificate.id}}/privkey.pem;
6+
{{else}}
7+
# Acme SSL
8+
include {{nginx_conf_dir}}/npm/conf.d/acme-challenge.conf;
9+
include {{nginx_conf_dir}}/npm/conf.d/include/ssl-ciphers.conf;
10+
ssl_certificate {{acme_certs_dir}}/npm-{{certificate.id}}/fullchain.pem;
11+
ssl_certificate_key {{acme_certs_dir}}/npm-{{certificate.id}}/privkey.pem;
12+
{{/if}}
13+
{{/if}}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{{#if certificate}}
2+
{{#if ssl_forced}}
3+
# Force SSL
4+
include {{nginx_conf_dir}}/npm/conf.d/include/force-ssl.conf;
5+
{{/if}}
6+
{{/if}}

backend/embed/nginx/_hsts.conf.hbs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{{#if certificate}}
2+
{{#if ssl_forced}}
3+
{{#if hsts_enabled}}
4+
# HSTS (ngx_http_headers_module is required) (63072000 seconds = 2 years)
5+
add_header Strict-Transport-Security "max-age=63072000;{{#if hsts_subdomains}} includeSubDomains;{{/if}} preload" always;
6+
{{/if}}
7+
{{/if}}
8+
{{/if}}

backend/embed/nginx/_listen.conf.hbs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
listen 80;
2+
3+
{{#if ipv6}}
4+
listen [::]:80;
5+
{{else}}
6+
#listen [::]:80;
7+
{{/if}}
8+
9+
{{#if certificate}}
10+
listen 443 ssl{% if http2_support %} http2{% endif %};
11+
{{#if ipv6}}
12+
listen [::]:443;
13+
{{else}}
14+
#listen [::]:443;
15+
{{/if}}
16+
{{/if}}
17+
18+
server_name{{#each domain_names}} {{this}}{{/each}};
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
___location {{path}} {
2+
proxy_set_header Host $host;
3+
proxy_set_header X-Forwarded-Scheme $scheme;
4+
proxy_set_header X-Forwarded-Proto $scheme;
5+
proxy_set_header X-Forwarded-For $remote_addr;
6+
proxy_set_header X-Real-IP $remote_addr;
7+
proxy_pass {{forward_scheme}}://{{forward_host}}:{{forward_port}}{{forward_path}};
8+
9+
{{#if access_list}}
10+
{{#if access_list.items}}
11+
# Authorization
12+
auth_basic "Authorization required";
13+
auth_basic_user_file {{npm_data_dir}}/access/{{access_list.id}};
14+
{{access_list.passauth}}
15+
{{/if}}
16+
17+
# Access Rules
18+
{{#each access_list.clients as |client clientIdx|}}
19+
{{client.rule}};
20+
{{/each}}deny all;
21+
22+
# Access checks must...
23+
{{#if access_list.satisfy}}
24+
{{access_list.satisfy}};
25+
{{/if}}
26+
{{/if}}
27+
28+
{{> inc_assets}}
29+
{{> inc_forced_ssl}}
30+
{{> inc_hsts}}
31+
32+
{{#if allow_websocket_upgrade}}
33+
proxy_set_header Upgrade $http_upgrade;
34+
proxy_set_header Connection $http_connection;
35+
proxy_http_version 1.1;
36+
{{/if}}
37+
38+
{{advanced_config}}
39+
}
40+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
server {
2+
listen 80;
3+
{{#if ipv6}}
4+
listen [::]:80;
5+
{{/if}}
6+
7+
server_name{{#each domain_names}} {{this}}{{/each}};
8+
access_log {{npm_data_dir}}/logs/acme-requests_access.log standard;
9+
error_log {{npm_data_dir}}/logs/acme-requests_error.log warn;
10+
{{nginx_conf_dir}}/npm/conf.d/include/letsencrypt-acme-challenge.conf;
11+
12+
___location / {
13+
return 404;
14+
}
15+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{{#if enabled}}
2+
server {
3+
{{> inc_listen}}
4+
{{> inc_certificates}}
5+
{{> inc_hsts}}
6+
{{> inc_forced_ssl}}
7+
8+
access_log {{npm_data_dir}}/logs/dead-host-{{id}}_access.log standard;
9+
error_log {{npm_data_dir}}/logs/dead-host-{{id}}_error.log warn;
10+
11+
{{advanced_config}}
12+
13+
{{#if use_default_location}}
14+
___location / {
15+
{{> inc_hsts}}
16+
return 404;
17+
}
18+
{{/if}}
19+
}
20+
{{/if}}

0 commit comments

Comments
 (0)