# nginx reverse proxy configuration
# Generated by RDT (Rambo Docker Tools)
# Upstream: {{ nginx_upstream | default('app:8000') }}
# To customise, edit this file and run `rdt add nginx-proxy` again (existing files are not overwritten).

worker_processes auto;

events {
    worker_connections 1024;
}

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

    sendfile        on;
    keepalive_timeout  65;

    # Gzip
    gzip on;
    gzip_types text/plain text/css application/json application/javascript text/xml application/xml;

    upstream backend {
        server {{ nginx_upstream | default('app:8000') }};
    }

    server {
        listen 80;
        server_name {{ nginx_server_name | default('localhost') }};

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

            proxy_set_header   Host              $host;
            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 $scheme;
            proxy_set_header   Upgrade           $http_upgrade;
            proxy_set_header   Connection        "upgrade";

            proxy_read_timeout  90s;
            proxy_connect_timeout 90s;
        }
    }
}

