Skip to content

Commit 6bdc90d

Browse files
committed
Add env vars for extra HSTS options
1 parent 1634d5c commit 6bdc90d

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ Environment variables (will overwrite other server configs)
155155
| HMD_S3_REGION | `ap-northeast-1` | AWS S3 region |
156156
| HMD_S3_BUCKET | no example | AWS S3 bucket name |
157157
| HMD_HSTS_ENABLE | ` true` | set to enable [HSTS](https://en.wikipedia.org/wiki/HTTP_Strict_Transport_Security) if HTTPS is also enabled (default is ` true`) |
158+
| HMD_HSTS_INCLUDE_SUBDOMAINS | `true` | set to include subdomains in HSTS (default is `true`) |
159+
| HMD_HSTS_MAX_AGE | `31536000` | max duration in seconds to tell clients to keep HSTS status (default is a year) |
160+
| HMD_HSTS_PRELOAD | `true` | whether to allow preloading of the site's HSTS status (e.g. into browsers) |
158161

159162
Application settings `config.json`
160163
---

app.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,18 @@
2727
"description": "whether to also use HSTS if HTTPS is enabled",
2828
"required": false
2929
},
30+
"HMD_HSTS_MAX_AGE": {
31+
"description": "max duration, in seconds, to tell clients to keep HSTS status",
32+
"required": false
33+
},
34+
"HMD_HSTS_INCLUDE_SUBDOMAINS": {
35+
"description": "whether to tell clients to also regard subdomains as HSTS hosts",
36+
"required": false
37+
},
38+
"HMD_HSTS_PRELOAD": {
39+
"description": "whether to allow at all adding of the site to HSTS preloads (e.g. in browsers)",
40+
"required": false
41+
},
3042
"HMD_DOMAIN": {
3143
"description": "domain name",
3244
"required": false

lib/config/environment.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ module.exports = {
1010
usessl: toBooleanConfig(process.env.HMD_USESSL),
1111
hsts: {
1212
enable: toBooleanConfig(process.env.HMD_HSTS_ENABLE),
13+
maxAgeSeconds: process.env.HMD_HSTS_MAX_AGE,
14+
includeSubdomains: toBooleanConfig(process.env.HMD_HSTS_INCLUDE_SUBDOMAINS),
15+
preload: toBooleanConfig(process.env.HMD_HSTS_PRELOAD)
1316
},
1417
protocolusessl: toBooleanConfig(process.env.HMD_PROTOCOL_USESSL),
1518
alloworigin: process.env.HMD_ALLOW_ORIGIN ? process.env.HMD_ALLOW_ORIGIN.split(',') : undefined,

0 commit comments

Comments
 (0)