#
# See: https://screego.net/#/proxy
#

upstream screego {
  # Set this to the address configured in
  # SCREEGO_SERVER_ADDRESS. Default 5050
  server 127.0.0.1:5050;
}

server {
  listen 80;

  # Here goes your domain / subdomain
  server_name screego.example.com;

  location / {
    # Proxy to screego
    proxy_pass         http://screego;
    proxy_http_version 1.1;

    # Set headers for proxying WebSocket
    proxy_set_header   Upgrade $http_upgrade;
    proxy_set_header   Connection "upgrade";
    proxy_redirect     http:// $scheme://;

    # Set proxy headers
    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 http;

    # The proxy must preserve the host because screego verifies it with the origin
    # for WebSocket connections
    proxy_set_header   Host $http_host;
  }
}
