1
1
server {
2
2
listen 80 default_server;
3
3
#listen [::]:80 default_server;
4
- server_name {{ getenv " BW_DOMAIN" "localhost" }};
5
- {{ if eq (getenv " BW_ENABLE_SSL") "true" }}
4
+ server_name {{{ String.Coalesce env. BW_DOMAIN " localhost" } }} ;
5
+ {{ # if ( String.Equal env. BW_ENABLE_SSL " true" ) }}
6
6
7
- return 301 https://{{ getenv " BW_DOMAIN" "localhost" }}$request_uri;
7
+ return 301 https://{{{ String.Coalesce env. BW_DOMAIN " localhost" } }} $request_uri;
8
8
}
9
9
10
10
server {
11
11
listen 443 ssl http2;
12
12
#listen [::]:443 ssl http2;
13
- server_name {{ getenv " BW_DOMAIN" "localhost" }};
13
+ server_name {{{ String.Coalesce env. BW_DOMAIN " localhost" } }} ;
14
14
15
- ssl_certificate /etc/bitwarden/{{ getenv " BW_SSL_CERT" "ssl.crt" }};
16
- ssl_certificate_key /etc/bitwarden/{{ getenv " BW_SSL_KEY" "ssl.key" }};
15
+ ssl_certificate /etc/bitwarden/{{{ String.Coalesce env. BW_SSL_CERT " ssl.crt" } }} ;
16
+ ssl_certificate_key /etc/bitwarden/{{{ String.Coalesce env. BW_SSL_KEY " ssl.key" } }} ;
17
17
ssl_session_timeout 30m;
18
18
ssl_session_cache shared:SSL:20m;
19
19
ssl_session_tickets off;
20
+ {{ #if (String.Equal env.BW_ENABLE_SSL_DH " true" )}}
20
21
21
- ssl_protocols {{ getenv "BW_SSL_PROTOCOLS" "TLSv1.2" }};
22
- ssl_ciphers "{{ getenv "BW_SSL_CIPHERS" "ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256" }}";
22
+ # Diffie-Hellman parameter for DHE ciphersuites, recommended 2048 bits
23
+ ssl_dhparam /etc/bitwarden/{{{ String.Coalesce env.BW_SSL_DH_CERT " dh.pem" }}} ;
24
+ {{ /if }}
25
+
26
+ ssl_protocols {{{ String.Coalesce env.BW_SSL_PROTOCOLS " TLSv1.2" }}} ;
27
+ ssl_ciphers "{{{ String.Coalesce env.BW_SSL_CIPHERS " ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256" }}} ";
23
28
# Enables server-side protection from BEAST attacks
24
29
ssl_prefer_server_ciphers on;
25
- {{ if eq (getenv " BW_ENABLE_SSL_CA") "true" }}
30
+ {{ # if ( String.Equal env. BW_ENABLE_SSL_CA " true" ) }}
26
31
27
32
# OCSP Stapling ---
28
33
# Fetch OCSP records from URL in ssl_certificate and cache them
29
34
ssl_stapling on;
30
35
ssl_stapling_verify on;
31
36
32
37
# Verify chain of trust of OCSP response using Root CA and Intermediate certs
33
- ssl_trusted_certificate /etc/bitwarden/{{ getenv " BW_SSL_CA_CERT" "ca.crt" }};
38
+ ssl_trusted_certificate /etc/bitwarden/{{{ String.Coalesce env. BW_SSL_CA_CERT " ca.crt" } }} ;
34
39
resolver 1.1.1.1 1.0.0.1 9.9.9.9 149.112.112.112 valid=300s;
35
- {{ end }}
40
+ {{ /if }}
36
41
37
42
include /etc/nginx/security-headers-ssl.conf;
38
- {{ end }}
43
+ {{ /if }}
39
44
include /etc/nginx/security-headers.conf;
40
- {{ if getenv " BW_REAL_IPS" }}
45
+ {{ # if ( String.IsNotNullOrWhitespace env. BW_REAL_IPS) }}
41
46
42
- {{ range (getenv " BW_REAL_IPS") }}
43
- set_real_ip_from {{ .Key }};
44
- {{ end }}
47
+ {{ #each ( String.Split env. BW_REAL_IPS " , " ) }}
48
+ set_real_ip_from {{{ String.Trim . } }} ;
49
+ {{ /each }}
45
50
real_ip_header X-Forwarded-For;
46
51
real_ip_recursive on;
47
- {{ end }}
52
+ {{ /if }}
48
53
49
54
location / {
50
55
root /app/Web;
51
- {{ if eq (getenv " BW_ENABLE_SSL") "true" }}
56
+ {{ # if ( String.Equal env. BW_ENABLE_SSL " true" ) }}
52
57
include /etc/nginx/security-headers-ssl.conf;
53
- {{ end }}
58
+ {{ /if }}
54
59
include /etc/nginx/security-headers.conf;
55
- add_header Content-Security-Policy "{{ getenv " BW_CSP" "default-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https://haveibeenpwned.com https://www.gravatar.com; child-src 'self' https://*.duosecurity.com https://*.duofederal.com; frame-src 'self' https://*.duosecurity.com https://*.duofederal.com; connect-src 'self' https://api.pwnedpasswords.com https://2fa.directory; object-src 'self' blob:;" }}";
60
+ add_header Content-Security-Policy "{{{ String.Coalesce env. BW_CSP " default-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https://haveibeenpwned.com https://www.gravatar.com; child-src 'self' https://*.duosecurity.com https://*.duofederal.com; frame-src 'self' https://*.duosecurity.com https://*.duofederal.com; connect-src 'self' https://api.pwnedpasswords.com https://2fa.directory; object-src 'self' blob:;" } }} ";
56
61
add_header X-Frame-Options SAMEORIGIN;
57
62
add_header X-Robots-Tag "noindex, nofollow";
58
63
}
@@ -64,9 +69,9 @@ server {
64
69
65
70
location = /app-id.json {
66
71
root /app/Web;
67
- {{ if eq (getenv " BW_ENABLE_SSL") "true" }}
72
+ {{ # if ( String.Equal env. BW_ENABLE_SSL " true" ) }}
68
73
include /etc/nginx/security-headers-ssl.conf;
69
- {{ end }}
74
+ {{ /if }}
70
75
include /etc/nginx/security-headers.conf;
71
76
proxy_hide_header Content-Type;
72
77
add_header Content-Type $fido_content_type;
@@ -81,14 +86,14 @@ server {
81
86
}
82
87
83
88
location /icons/ {
84
- {{ if eq (getenv " BW_ICONS_PROXY_TO_CLOUD") "true" }}
89
+ {{ # if ( String.Equal env. BW_ICONS_PROXY_TO_CLOUD " true" ) }}
85
90
proxy_pass https://icons.bitwarden.net/;
86
91
proxy_set_header Host icons.bitwarden.net;
87
92
proxy_set_header X-Forwarded-For $remote_addr;
88
93
proxy_ssl_server_name on;
89
- {{ else }}
94
+ {{ else }}
90
95
proxy_pass http://localhost:5004/;
91
- {{ end }}
96
+ {{ /if }}
92
97
}
93
98
94
99
location /notifications/ {
@@ -107,38 +112,38 @@ server {
107
112
108
113
location /sso {
109
114
proxy_pass http://localhost:5007;
110
- {{ if eq (getenv " BW_ENABLE_SSL") "true" }}
115
+ {{ # if ( String.Equal env. BW_ENABLE_SSL " true" ) }}
111
116
include /etc/nginx/security-headers-ssl.conf;
112
- {{ end }}
117
+ {{ /if }}
113
118
include /etc/nginx/security-headers.conf;
114
119
add_header X-Frame-Options SAMEORIGIN;
115
120
}
116
121
117
122
location /identity {
118
123
proxy_pass http://localhost:5005;
119
- {{ if eq (getenv " BW_ENABLE_SSL") "true" }}
124
+ {{ # if ( String.Equal env. BW_ENABLE_SSL " true" ) }}
120
125
include /etc/nginx/security-headers-ssl.conf;
121
- {{ end }}
126
+ {{ /if }}
122
127
include /etc/nginx/security-headers.conf;
123
128
add_header X-Frame-Options SAMEORIGIN;
124
129
}
125
130
126
131
location /admin {
127
132
proxy_pass http://localhost:5000;
128
- {{ if eq (getenv " BW_ENABLE_SSL") "true" }}
133
+ {{ # if ( String.Equal env. BW_ENABLE_SSL " true" ) }}
129
134
include /etc/nginx/security-headers-ssl.conf;
130
- {{ end }}
135
+ {{ /if }}
131
136
include /etc/nginx/security-headers.conf;
132
137
add_header X-Frame-Options SAMEORIGIN;
133
138
}
134
139
135
- {{ if eq (getenv "BW_ENABLE_KEY_CONNECTOR") "true" }}
136
- location /key-connector/ {
137
- proxy_pass {{ getenv "BW_KEY_CONNECTOR_INTERNAL_URL"}}/;
138
- }
139
- {{ end }}
140
-
141
140
location /scim/ {
142
141
proxy_pass http://localhost:5002/;
143
142
}
143
+ {{ #if (String.Equal env.BW_ENABLE_KEY_CONNECTOR " true" )}}
144
+
145
+ location /key-connector/ {
146
+ proxy_pass {{{ env.BW_KEY_CONNECTOR_INTERNAL_URL }}} /;
147
+ }
148
+ {{ /if }}
144
149
}
0 commit comments