Skip to content

Commit

Permalink
[nginx] allow enabling proxy_ssl_verify
Browse files Browse the repository at this point in the history
[nginx] proxy ssl verification off by default

because it would be off in the resulting docker image
so better to have it the same in development
  • Loading branch information
mikz committed Mar 27, 2017
1 parent 6c63287 commit 8349947
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 6 deletions.
3 changes: 1 addition & 2 deletions apicast/apicast.d/proxy_ssl.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# This file is not in the built docker image and have to be added by hand.

proxy_ssl_trusted_certificate ca-bundle.crt;
proxy_ssl_verify on;
proxy_ssl_verify off;
4 changes: 0 additions & 4 deletions apicast/conf.d/apicast.conf
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ location @out_of_band_authrep_action {
}
}

proxy_ssl_server_name on;
proxy_ssl_name $http_host;
proxy_ssl_verify_depth 5;

location / {
set $cached_key null;
set $credentials null;
Expand Down
2 changes: 2 additions & 0 deletions apicast/conf/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ http {
server_name _;
underscores_in_headers on;

include ../http.d/ssl.conf;

include ../apicast.d/*.conf;
include ../conf.d/apicast.conf;
}
Expand Down
6 changes: 6 additions & 0 deletions apicast/http.d/lua_ssl.conf → apicast/http.d/ssl.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@
#
lua_ssl_verify_depth 5;
lua_ssl_trusted_certificate ca-bundle.crt;

proxy_ssl_server_name on;
proxy_ssl_name $http_host;
proxy_ssl_verify_depth 5;

proxy_ssl_trusted_certificate ca-bundle.crt;
20 changes: 20 additions & 0 deletions examples/ssl-verification/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# SSL/TLS Verification

APIcast supports certificate verification against trusted CAs. This feature is off by default because some environments use custom CAs and would make those connections fail by default.

## Upstream verification

This validation is controller by `proxy_ssl_*` nginx directives. Everything is set up to use default OS trusted certificates. Only step needed is to add custom configuration to enable the verification:

```nginx
# apicast.d/proxy_ssl.conf
proxy_ssl_verify on;
```

## 3scale AMP verification

To enable verification for connections between APIcast and 3scale AMP you'll need to set `OPENSSL_VERIFY` environment variable. Everything is set up to use the default OS trusted certificate chain.

```shell
docker run --env OPENSSL_VERIFY=true apicast
```
41 changes: 41 additions & 0 deletions examples/ssl-verification/badssl.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"services": [
{
"id": "wrong-host",
"backend_version": 1,
"proxy": {
"api_backend": "https://wrong.host.badssl.com",
"hosts": [
"wrong.host.badssl.com"
],
"proxy_rules": [
{
"http_method": "GET",
"pattern": "/",
"metric_system_name": "hits",
"delta": 1
}
]
}
},
{
"id": "ok-host",
"backend_version": 1,
"proxy": {
"api_backend": "https://badssl.com",
"hosts": [
"badssl.com"
],
"proxy_rules": [
{
"http_method": "GET",
"pattern": "/",
"metric_system_name": "hits",
"delta": 1
}
]
}
}
]
}

1 change: 1 addition & 0 deletions examples/ssl-verification/proxy_ssl.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
proxy_ssl_verify on;

0 comments on commit 8349947

Please sign in to comment.