jupyter notebook websockets in aws

<virtualhost *:80>
  ProxyPreserveHost On
  ProxyRequests Off

  ServerName notebook.your-domain.com

  # redirect all requests to https
  RewriteEngine On
  RewriteCond %{HTTP:X-Forwarded-Proto} !https
  RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
  SetEnv HTTPS 1

  # allow web-sockets
  RewriteEngine On
  RewriteCond %{HTTP:Upgrade} =websocket [NC]
  RewriteRule /(.*)           ws://localhost:8888/$1 [P,L]
  RewriteCond %{HTTP:Upgrade} !=websocket [NC]
  RewriteRule /(.*)           http://localhost:8888/$1 [P,L]

  # forward to specific port
  ProxyPass / http://localhost:8888/
  ProxyPassReverse / http://localhost:8888/
</virtualhost>