<% if File.exist?(@ssl_cert) && File.exist?(@ssl_key) -%>
# Generated by Chef
upstream _drone {
  server   localhost:<%= @upstream_port %>;
}

server {
  server_name <%= @server_name %>;
  listen 443 ssl http2;
  listen [::]:443 ssl http2;

  ssl_certificate     <%= @ssl_cert %>;
  ssl_certificate_key <%= @ssl_key %>;

  add_header Strict-Transport-Security "max-age=31536000";

  # Send real IP to the Docker container
  set_real_ip_from 127.0.0.1;
  set_real_ip_from 172.17.0.1;
  real_ip_header X-Forwarded-For;

  client_max_body_size 20M;

  location / {
    # Increase number of buffers. Default is 8
    proxy_buffers 1024 8k;

    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    proxy_pass http://_drone;
    proxy_http_version 1.1;
  }
}
<% end -%>
