
user  nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;
    charset       utf-8;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    gzip  on;

    server {
        listen      80;
        server_name localhost default;

        location /static {
            alias /nyaa-static;
        }

        # fix kibana redirecting to localhost/kibana (without the port)
        rewrite ^/kibana$ http://$http_host/kibana/ permanent;
        location /kibana/ {
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'upgrade';
            proxy_cache_bypass $http_upgrade;            

            proxy_set_header Host 'kibana';
            proxy_set_header X-Real-IP $remote_addr;

            proxy_pass http://kibana:5601/;
        }

        location / {
            include    /etc/nginx/uwsgi_params;
            uwsgi_pass nyaa-flask:5000;
        }
    }
}
