server {
  root /home/user;
  index index.html;

  listen 443 ssl;
  
  ssl_certificate /etc/letsencrypt/live/ketrenos.com/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/ketrenos.com/privkey.pem;

  access_log /var/log/nginx/access.log;
  error_log /var/log/nginx/error.log;

  # proxy_pass has automatic redirect from v1 -> v1/
  # Set the API redirect early in case endpoints have similar names
  # to other location matches.
  location /api/v1/ {
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header Host $http_host;
    proxy_set_header X-NginX-Proxy true;
    proxy_pass_header Set-Cookie;
    proxy_pass_header P3P;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_pass http://localhost:8930/api/v1/;
  }

  # Set tail-pre injection for log files
  location ~ .*/*\.log$ {
    add_header Cache-Control "no-cache";
    add_before_body /tail-pre.html;
    default_type text/html;
    add_after_body /tail-post.html;
  }
  location ~ /tail.*\.(html|js|css) {
    root /home/user/client/public/;
  }

  # 'active.conf' is copied during docker build based on whether
  # DEVELOPMENT is set (development.conf) or not (production.conf)
  include snippets/active.location;
 
  location ~ /(db|conf) {
    deny all;
    return 404;
  }
}
