# NGINX configuration for KA Lite
#
# Upstream KA-Lite server uses port 7007
# Nginx proxy for KA-Lite uses port 8008
#
# If you want the website to be accessible at a different port, change
#  PROXY_PORT = nnnn setting in /var/ka-lite/.kalite/settings.py
# and change the below accordingly.
upstream kalite {
    server 127.0.0.1:7007;
}
server {
    listen 8008;
    # Default value, overwritten in nginx.d
    set $kalite_home {{ kalite_root }};
    include /etc/ka-lite/nginx.d/*.conf;
    location /static {
        alias   $kalite_home/httpsrv/static/;
    }
    location /media {
        alias   $kalite_home/httpsrv/media/;
    }
    location /content {
        alias   $kalite_home/content/;
    }
    location /favicon.ico {
        empty_gif;
    }
    location / {
        proxy_set_header Host $http_host;
        proxy_set_header X-Scheme $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_pass http://kalite;
        error_page 502 = @502;
    }
    location @502 {
        types { }
        default_type "text/html";
        return 502 "