server {
  listen 80;
  listen [::]:80;
  server_name a8c-localtunnel.cyou *.a8c-localtunnel.cyou;
  return 301 https://$host$request_uri;
}
server {
  listen 443 ssl;
  server_name a8c-localtunnel.cyou *.a8c-localtunnel.cyou;
  ssl_certificate /etc/letsencrypt/live/a8c-localtunnel.cyou/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/a8c-localtunnel.cyou/privkey.pem;
  include /etc/letsencrypt/options-ssl-nginx.conf;
  ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;

  location / {
    proxy_set_header   X-Forwarded-For $remote_addr;
    proxy_set_header   X-Real-IP $remote_addr;
    proxy_set_header   Host $http_host;
    proxy_set_header   Connection 'upgrade';
    # proxy_set_header Connection "";

    proxy_set_header X-Forwarded-Proto https;

    proxy_cache_bypass $http_upgrade;
    proxy_http_version 1.1; 
    proxy_pass         http://127.0.0.1:1234;

    # Fix for "146656 upstream sent too big header while reading response header from upstream"
    # https://ma.ttias.be/nginx-proxy-upstream-sent-big-header-reading-response-header-upstream
    proxy_buffer_size          128k;
    proxy_buffers              4 256k;
    proxy_busy_buffers_size    256k;

    # Ugly fix for Connection timed out error
    proxy_send_timeout 150; 
    proxy_read_timeout 150; 

  }
}
