## MikroTik Manager behind SWAG (nginx)
## Place in SWAG at: /config/nginx/proxy-confs/manager.subdomain.conf
##
## Replace 192.0.2.10 with the address of the host running the manager, and
## adjust the port if you did not keep the default 3000.
##
## In the SWAG container environment set:
##   SUBDOMAINS=manager
##   VALIDATION=http
## (or add "manager" to your existing SUBDOMAINS list)

server {
    listen 443 ssl;
    listen [::]:443 ssl;
    http2 on;

    server_name manager.*;

    include /config/nginx/ssl.conf;

    # Configuration backups and firmware uploads are not small.
    client_max_body_size 0;

    location / {
        include /config/nginx/proxy.conf;
        include /config/nginx/resolver.conf;

        set $upstream_app 192.0.2.10;
        set $upstream_port 3000;
        set $upstream_proto http;
        proxy_pass $upstream_proto://$upstream_app:$upstream_port;
    }

    # WebSocket endpoint. Without this location the interface loads and then
    # never updates: device status, command output, upgrade and backup progress
    # all arrive over this connection.
    location /ws {
        include /config/nginx/proxy.conf;
        include /config/nginx/resolver.conf;

        set $upstream_app 192.0.2.10;
        set $upstream_port 3000;
        set $upstream_proto http;
        proxy_pass $upstream_proto://$upstream_app:$upstream_port;
    }
}
