summaryrefslogtreecommitdiff
path: root/configs/etc/nginx/sites-available/exchange
blob: 7d8b6e9828f37f5e7e58be70fbb2b07e7582c49f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
upstream exchange {
  least_conn;
  keepalive 20;
  # EXCHANGE_PROCESSES e.g.
  # server exch.perf.taler:8080;
  # server exch.perf.taler:80;
  # <SERVERS_HERE>
}

# This format is expected by promtail (configs/etc/monitor/promtail.yaml)
log_format taler 'm=$request_method uri=$uri s=$status '
		 'q=$args '
                 'uct=$upstream_connect_time '
                 'urt=$upstream_response_time '
                 'rt=$request_time '
                 'rl=$request_length '
                 'bs=$bytes_sent';

# Disable logging of HEAD requests
map $request_method $log_line {
  'HEAD' 0;
  default 1;
}

# Setup a cache with 1GB storage for our exchange
# https://www.nginx.com/blog/nginx-caching-guide/
proxy_cache_path /var/cache/proxy levels=1:2 keys_zone=exchange:1m inactive=1m max_size=1g;

server {
  listen 80;
  listen 443 ssl;

  ssl_certificate /etc/ssl/proxy.cert.pem;
  ssl_certificate_key /etc/ssl/proxy.key.pem;

  server_name <PROXY_DOMAIN_HERE>;

  access_log syslog:server=localhost,facility=user,tag=taler_exchange_proxy,severity=info taler if=$log_line;

  allow 172.16.0.0/12;
  deny all;

  keepalive_timeout 10;
  keepalive_requests 100000;

  location / {

     proxy_cache exchange;
     # Dont cache requests too early
     proxy_cache_min_uses 16;

     proxy_pass http://exchange;
     proxy_redirect off;

  }
}

server {
  listen 80;
  server_name localhost;

  location /stub_status {
     stub_status;
     access_log off;
  }
}