server {
  listen 80;
  rewrite ^(.*)$ https://$host$1 permanent;
}

server {
  listen 443;

  ssl on;
  ssl_certificate ssl.crt;
  ssl_certificate_key ssl.key;

  ssl_session_timeout 5m;

  ssl_protocols SSLv3 TLSv1;
  ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;
  ssl_prefer_server_ciphers on;

  satisfy any;
  deny all;
  auth_basic "Log in as user rethinkdb with your chosen password";
  auth_basic_user_file htpasswd;

  location ~ .* {
    proxy_pass http://localhost:8080;
    proxy_redirect off;
    proxy_buffering off;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Authorization "";
    proxy_set_header X-Forwarded-Ssl on;
  }
}
