bigchaindb/k8s/nginx/container/nginx.conf.template
Krish cc66d5aaa5 Single node setup (#1418)
* Add more tools to the toolbox container

* Add mongodb monitoring agent
* Add a bigchaindb/mongodb-monitoring-agent container that includes the
monitoring agent.
* It makes use of an api key provided by MongoDB Cloud Manager. This is
included in the configuration/config-map.yaml file.

* Changes to mongodb StatefulSet configuration
Changes to bump up mongodb version to v3.4.3.
Add configuration settings for mongodb instance name in ConfigMap.
Split the mongodb service to a new configuration file.

* Modify bigchaindb deployment config
* Bugfix to remove keyring field for the first node.
* Split the mongodb service to a new configuration file.

* Add mongodb backup agent
* Add a bigchaindb/mongodb-backup-agent container that includes the
backup agent.
* It makes use of an api key provided by MongoDB Cloud Manager. This is
included in the configuration/config-map.yaml file.

* Changes to nginx deployment config
* Allow 'all' by default for now. This is included in the
configuration/config-map.yaml file.
* Dynamically resolve DNS addresses of our backend services; cache DNS
resolution for 20s.
* Configure DNS based on user provided resolver. This helps in user
deciding to provide 8.8.8.8 or a custom DNS for name resolution. For k8s
deployments, we use the hardcoded k8s DNS IP of 10.0.0.10.

* Changes to nginx-3scale deployment config
* Use the common ConfigMap in configuration/config-map.yaml file.

* Removing prefix `v` from the docker tag for mongodb-monitoring-agent and mongodb containers

* Bumping up version for nginx-3scale container

* Add small helper scripts for docker build and push of mongodb monitoring
and backup agents

* Documentation for setting up the first node with monitoring and backup
agents
2017-04-21 14:41:12 +02:00

108 lines
2.9 KiB
Plaintext

worker_processes 2;
daemon off;
user nobody nogroup;
pid /tmp/nginx.pid;
error_log /etc/nginx/nginx.error.log;
events {
worker_connections 256;
accept_mutex on;
use epoll;
}
http {
server_names_hash_bucket_size 128;
access_log /etc/nginx/nginx.access.log combined buffer=16k flush=5s;
# allow 10 req/sec from the same IP address, and store the counters in a
# `zone` or shared memory location tagged as 'one'.
limit_req_zone $binary_remote_addr zone=one:10m rate=10r/s;
# enable logging when requests are being throttled
limit_req_log_level notice;
# the http status code to return to the client when throttling;
# 429 is for TooManyRequests,
# ref. RFC 6585
limit_req_status 429;
resolver DNS_SERVER valid=20s;
map $remote_addr $bdb_backend {
default BIGCHAINDB_BACKEND_HOST;
}
server {
listen BIGCHAINDB_FRONTEND_PORT;
# server_name "FRONTEND_DNS_NAME";
underscores_in_headers on;
# max client request body size: avg transaction size
client_max_body_size 15k;
# keepalive connection settings
keepalive_timeout 20s;
# `slowloris` attack mitigation settings
client_body_timeout 10s;
client_header_timeout 10s;
location / {
proxy_ignore_client_abort on;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_redirect off;
# TODO proxy_set_header X-Forwarded-Proto https;
# limit requests from the same client, allow `burst` to 20 r/s,
# `nodelay` or drop connection immediately in case it exceeds this
# threshold.
limit_req zone=one burst=20 nodelay;
proxy_pass http://$bdb_backend:BIGCHAINDB_BACKEND_PORT;
}
}
}
# NGINX stream block for TCP and UDP proxies
stream {
log_format mdb_log '[$time_iso8601] $realip_remote_addr $remote_addr '
'$proxy_protocol_addr $proxy_protocol_port '
'$protocol $status $session_time $bytes_sent '
'$bytes_received "$upstream_addr" "$upstream_bytes_sent" '
'"$upstream_bytes_received" "$upstream_connect_time" ';
access_log /etc/nginx/nginx.stream.access.log mdb_log buffer=16k flush=5s;
# define a zone 'two' of size 10 megabytes to store the counters
# that hold number of TCP connections from a specific IP address
limit_conn_zone $binary_remote_addr zone=two:10m;
# enable logging when connections are being throttled
limit_conn_log_level notice;
resolver DNS_SERVER valid=20s;
map $remote_addr $mdb_backend {
default MONGODB_BACKEND_HOST;
}
server {
listen MONGODB_FRONTEND_PORT so_keepalive=10m:1m:5;
preread_timeout 30s;
tcp_nodelay on;
# whitelist
#MONGODB_WHITELIST
allow all;
# deny access to everyone else
deny all;
# allow 16 connections from the same IP address
limit_conn two 16;
proxy_pass $mdb_backend:MONGODB_BACKEND_PORT;
}
}