Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Commit

Permalink
Merge #1043
Browse files Browse the repository at this point in the history
1043: Add PUBLIC_PROTOCOL to allow serving from a HTTP endpoint r=notriddle a=tommilligan

Closes #1042 

This PR introduces a new environment variable, `PUBLIC_PROTOCOL`. If unset, the value defaults to the current hardcoded value of `https`, with no change in behaviour:

```log
13:46:22.316 pid=<0.2038.0> [info] Running BorsNG.Endpoint with cowboy 1.1.2 at 0.0.0.0:39103 (http)
13:46:22.318 pid=<0.2005.0> [info] Access BorsNG.Endpoint at https://172.17.0.1:39103
```

If `PUBLIC_PROTOCOL=http` is set, the endpoint is updated accordingly:

```log
13:48:59.885 pid=<0.2038.0> [info] Running BorsNG.Endpoint with cowboy 1.1.2 at 0.0.0.0:39103 (http)
13:48:59.887 pid=<0.2005.0> [info] Access BorsNG.Endpoint at http://172.17.0.1:39103
```

This allows the app to run at a HTTP endpoint if HTTPS is not required.

Co-authored-by: Tom Milligan <tom@reinfer.io>
  • Loading branch information
bors[bot] and tommilligan committed Nov 5, 2020
2 parents 672b04f + 9c24749 commit c16a89b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion app.json
Expand Up @@ -24,9 +24,13 @@
"description": "Where this website will be running (probably <app name>.herokuapp.com)"
},
"PUBLIC_PORT": {
"description": "HTTPS port number on PUBLIC_HOST",
"description": "Port number on PUBLIC_HOST",
"value": "443"
},
"PUBLIC_PROTOCOL": {
"description": "Protocol to use when connecting to PUBLIC_HOST:PUBLIC_PORT",
"value": "https"
},
"SECRET_KEY_BASE": {
"description": "A secret key for verifying the integrity of cookies",
"generator": "secret"
Expand Down
2 changes: 1 addition & 1 deletion config/prod.secret.exs
Expand Up @@ -11,7 +11,7 @@ config :bors, BorsNG.Endpoint,
http: [port: {:system, "PORT"}],
url: [
host: {:system, "PUBLIC_HOST"},
scheme: "https",
scheme: {:system, "PUBLIC_PROTOCOL", "https"},
port: {:system, :integer, "PUBLIC_PORT", 443}
],
check_origin: false,
Expand Down

0 comments on commit c16a89b

Please sign in to comment.