<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jaime G.E. on Medium]]></title>
        <description><![CDATA[Stories by Jaime G.E. on Medium]]></description>
        <link>https://medium.com/@jaimege?source=rss-cdc4cec79883------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*UIaqiYPDJgGRNsYPG74yow.jpeg</url>
            <title>Stories by Jaime G.E. on Medium</title>
            <link>https://medium.com/@jaimege?source=rss-cdc4cec79883------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 17:50:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jaimege/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Automating Network Threat Isolation: A Multi-Agent AI Approach]]></title>
            <link>https://medium.com/@jaimege/automating-network-threat-isolation-a-multi-agent-ai-approach-ff1faca35d97?source=rss-cdc4cec79883------2</link>
            <guid isPermaLink="false">https://medium.com/p/ff1faca35d97</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[crew-ai]]></category>
            <dc:creator><![CDATA[Jaime G.E.]]></dc:creator>
            <pubDate>Sun, 31 May 2026 16:43:36 GMT</pubDate>
            <atom:updated>2026-05-31T16:43:36.275Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Turning passive intra-VLAN network telemetry into an active, self-defending architecture using Local LLMs, Zeek, and Agentic AI.</em></p><p>In a modern Security Operations Center (SOC), perimeter defenses like firewalls and secure web gateways are heavily monitored. However, when an attacker bypasses the edge, intra-VLAN communication — often referred to as East-West traffic — frequently goes uninspected. If an adversary compromises a web server and begins lateral movement toward a database on the same virtual switch, edge firewalls lack the visibility to intervene.</p><p>This is where Network Detection and Response (NDR) becomes critical. By capturing raw traffic directly at the switch level (or via container network namespaces), security teams regain visibility. Yet, this visibility introduces a secondary challenge: alert fatigue. While SIEMs ingest gigabytes of data flawlessly, manually correlating a localized port scan, an application-layer exploit, and subsequent C2 beaconing remains a slow, reactive process.</p><p>This article explores a proof-of-concept architecture that transitions from passive logging to active defense. We will examine how to build a locally hosted, multi-agent AI SOC that can ingest telemetry, query Threat Intelligence, and automatically isolate compromised endpoints in real-time — followed by a frank discussion on the guardrails required to safely deploy such automation in production.</p><h3>The Cyber Range: A Local Lab Environment</h3><p>To test this architecture safely without cloud API dependencies or data leakage, the environment is containerized using Docker, running entirely on local hardware. The stack consists of four core elements:</p><ul><li><strong>The Target Application (victim-dvwa):</strong> A standard vulnerable web application acting as the initial vector.</li><li><strong>The Threat Actor Simulation (advanced-attacker):</strong> A Metasploit instance executing an automated, multi-stage attack loop.</li><li><strong>The NDR Sensor (zeek-ndr):</strong> A Zeek monitor attached directly to the target’s network namespace to capture East-West traffic without requiring complex port-mirroring.</li><li><strong>The Orchestration Layer (soc_crew.py):</strong> A Python script leveraging CrewAI and a local Llama 3.1 (8B) model hosted via Ollama to process logs and execute mitigations.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aL8bmsgwfjzEoyiJjqeHeA.png" /></figure><h3>Constructing the Infrastructure</h3><p>To understand the architecture, let’s break down the components and the design decisions behind each one.</p><h4>1. The Network and Sensor (Docker Compose)</h4><p>We define an isolated bridge network. Notice how the zeek-ndr service uses network_mode: &quot;container:victim-dvwa&quot;. This is a crucial configuration: it allows Zeek to sniff traffic exactly as the target application sees it, capturing intra-VLAN packets effectively without complex port-mirroring setups..</p><pre>networks:<br>  cyber-range:<br>    driver: bridge<br><br>services:<br>  victim-dvwa:<br>    image: vulnerables/web-dvwa:latest<br>    container_name: victim-dvwa<br>    networks:<br>      - cyber-range<br>    ports:<br>      - &quot;8080:80&quot;<br><br>  advanced-attacker:<br>    image: metasploitframework/metasploit-framework:latest<br>    container_name: advanced-attacker<br>    user: root<br>    networks:<br>      - cyber-range<br>    volumes:<br>      - ./attack.rc:/attack.rc:ro<br>    entrypoint: [&quot;./msfconsole&quot;, &quot;-q&quot;, &quot;-r&quot;, &quot;/attack.rc&quot;]<br>    depends_on:<br>      - victim-dvwa<br><br>  zeek-ndr:<br>    image: blacktop/zeek:latest<br>    container_name: zeek-ndr<br>    network_mode: &quot;container:victim-dvwa&quot; # Sniffs victim&#39;s traffic directly<br>    working_dir: /logs<br>    volumes:<br>      - ./logs:/logs<br>    entrypoint: [&quot;/bin/sh&quot;, &quot;-c&quot;, &quot;zeek -C -i eth0 LogAscii::use_json=T&quot;]<br>    depends_on:<br>      - victim-dvwa</pre><h4>2. The Threat Simulation (Ruby Script)</h4><p>To test the AI’s correlation capabilities, the attacker must generate distinct types of network noise. This script forces Metasploit into an automated loop: volumetric scanning (SYN port sweep), payload delivery (Shellshock RCE), and persistent C2 communication (APT29 Beaconing).</p><pre>require &#39;net/http&#39;<br>require &#39;uri&#39;<br><br>print_line(&quot;[*] Advanced Threat Actor Initialized. Target: victim-dvwa&quot;)<br><br>loop do<br>  # Phase 1: Network Reconnaissance (Triggers conn.log anomalies)<br>  print_line(&quot;[*] [Phase 1] Launching Stealth SYN Scan...&quot;)<br>  run_single(&quot;use auxiliary/scanner/portscan/syn&quot;)<br>  run_single(&quot;set RHOSTS victim-dvwa&quot;)<br>  run_single(&quot;set PORTS 80,443,22,3306&quot;)<br>  run_single(&quot;set THREADS 5&quot;)<br>  run_single(&quot;run&quot;)<br>  sleep(5)<br><br>  # Phase 2: Application Exploitation (Triggers http.log payload signatures)<br>  print_line(&quot;[*] [Phase 2] Simulating Shellshock (CVE-2014-6271) RCE...&quot;)<br>  run_single(&quot;use auxiliary/scanner/http/apache_mod_cgi_bash_env&quot;)<br>  run_single(&quot;set RHOSTS victim-dvwa&quot;)<br>  run_single(&quot;set TARGETURI /login.php&quot;)<br>  run_single(&quot;run&quot;)<br>  sleep(5)<br><br>  # Phase 3: Command &amp; Control (Triggers http.log anomalous User-Agents)<br>  print_line(&quot;[*] [Phase 3] Simulating Encrypted C2 Beaconing...&quot;)<br>  10.times do<br>    begin<br>      uri = URI.parse(&quot;http://victim-dvwa/api/v1/update&quot;)<br>      request = Net::HTTP::Get.new(uri)<br>      request[&quot;User-Agent&quot;] = &quot;APT29-Beacon/2.0&quot; # Intentional IOC<br>      response = Net::HTTP.start(uri.hostname, uri.port) { |http| http.request(request) }<br>    rescue<br>    end<br>    sleep(2)<br>  end<br><br>  print_line(&quot;[*] Attack cycle complete. Sleeping 30 seconds...&quot;)<br>  sleep(30)<br>end</pre><h3>Architecting the Orchestration Layer</h3><p>Feeding a massive JSON file of network logs into a single LLM prompt often results in context contamination. Models can become overwhelmed, improperly correlating the IP attributes of a volumetric scan with the payload of a separate application-layer attack.</p><p>To address this, we use Agent Specialization. We orchestrate a CrewAI pipeline where micro-segmented agents follow narrow, explicit directives — reducing hallucination rates and improving accuracy.</p><h4>Defining Active Defense Tools</h4><p>To enable an active response, the orchestration layer requires programmatic tools. Here, we define a Python function that executes host OS commands to isolate the source of the attack.</p><pre>import json<br>import os<br>import subprocess<br>from crewai import Agent, Task, Crew, Process, LLM<br>from crewai.tools import tool<br><br># Initialize Local LLM natively via Ollama for private, zero-cost inference<br>local_llm = LLM(model=&quot;ollama/llama3.1&quot;, base_url=&quot;http://localhost:11434&quot;, temperature=0.1)<br><br>@tool(&quot;Network Isolation Tool&quot;)<br>def isolate_target(ip_address: str) -&gt; str:<br>    &quot;&quot;&quot;<br>    CRITICAL TOOL: Blocks an IP address at the network level if a critical threat is confirmed.<br>    &quot;&quot;&quot;<br>    print(&quot;\n🚨 [ACTIVE RESPONSE TRIGGERED] 🚨&quot;)<br>    print(f&quot;[*] SOC Manager is initiating REAL ISOLATION for IP: {ip_address}&quot;)<br>    <br>    try:<br>        # In a production environment, this would map to a Firewall or EDR API.<br>        # For this lab, we execute a Docker stop command on the host.<br>        subprocess.run([&quot;docker&quot;, &quot;stop&quot;, &quot;advanced-attacker&quot;], capture_output=True, text=True, check=True)<br>        print(&quot;[+] SUCCESS: Threat neutralized. Container stopped.&quot;)<br>        return f&quot;SUCCESS: The IP {ip_address} has been successfully isolated.&quot;<br>    except subprocess.CalledProcessError as e:<br>        return f&quot;FAILED: Could not isolate the target. Error: {e.stderr}&quot;<br><br>@tool(&quot;Threat Intelligence Database&quot;)<br>def threat_intel_tool(indicator: str) -&gt; str:<br>    &quot;&quot;&quot;Validates specific string indicators against known threat actors.&quot;&quot;&quot;<br>    known_threats = {<br>        &quot;APT29-Beacon&quot;: &quot;CRITICAL: Known indicator of APT29 botnet. C2 operations.&quot;,<br>        &quot;() {&quot;: &quot;CRITICAL: Shellshock (CVE-2014-6271) command injection attempt.&quot;,<br>    }<br>    for key, intel in known_threats.items():<br>        if key.lower() in indicator.lower():<br>            return intel<br>    return &quot;CLEAN: No threat intelligence associated with this indicator.&quot;</pre><h4>Building the Agents and Assembling the Crew</h4><p>Notice how we divide the cognitive load: one agent handles network volumes, another handles web application payloads, and a third orchestrates the final response.</p><pre># Helper to ingest logs<br>def get_latest_logs(log_path, num_lines=20):<br>    with open(log_path, &#39;r&#39;) as file:<br>        parsed = [json.loads(line.strip()) for line in file.readlines()[-num_lines:] if line.strip()]<br>        return json.dumps(parsed, indent=2)<br><br>conn_data = get_latest_logs(&quot;logs/conn.log&quot;, num_lines=20)<br>http_data = get_latest_logs(&quot;logs/http.log&quot;, num_lines=20)<br><br># AGENT 1: Focuses purely on L3/L4 volumetric traffic<br>network_analyst = Agent(<br>    role=&#39;Network Traffic Analyst&#39;,<br>    goal=&#39;Identify port scanning and anomalous TCP/UDP connections.&#39;,<br>    backstory=&#39;You look for reconnaissance patterns. You only care about IPs, ports, and states.&#39;,<br>    verbose=True, llm=local_llm<br>)<br><br># AGENT 2: Focuses purely on L7 payloads and C2 indicators<br>web_analyst = Agent(<br>    role=&#39;Web Security Analyst&#39;,<br>    goal=&#39;Identify application-layer attacks like C2 Beaconing and RCE.&#39;,<br>    backstory=&#39;You analyze HTTP logs to find malicious User-Agents or payloads.&#39;,<br>    verbose=True, tools=[threat_intel_tool], llm=local_llm<br>)<br><br># AGENT 3: The decision maker. Possesses the Network Isolation Tool.<br>soc_manager = Agent(<br>    role=&#39;SOC Incident Manager&#39;,<br>    goal=&#39;Review analyst findings, execute active response actions, and generate a report.&#39;,<br>    backstory=&quot;Lead Incident Commander. If a critical threat is confirmed, isolate the attacker immediately using the Network Isolation Tool before writing the report.&quot;,<br>    verbose=True, tools=[isolate_target], llm=local_llm<br>)<br><br># Define tasks to explicitly pass the specialized telemetry to the correct agent<br>task_network = Task(description=f&quot;Analyze conn.log:\n{conn_data}&quot;, expected_output=&quot;Network summary.&quot;, agent=network_analyst)<br>task_web = Task(description=f&quot;Analyze http.log:\n{http_data}&quot;, expected_output=&quot;Web threats summary.&quot;, agent=web_analyst)<br>task_manager = Task(<br>    description=&quot;&quot;&quot;Review findings. YOUR DIRECTIVES:<br>    1. If a critical threat is identified, YOU MUST execute the &#39;Network Isolation Tool&#39; against the attacker&#39;s IP.<br>    2. Create a final &#39;AI INCIDENT RESPONSE REPORT&#39;.&quot;&quot;&quot;,<br>    expected_output=&quot;Final Incident Response report.&quot;,<br>    agent=soc_manager<br>)<br><br># Assemble and launch the sequential pipeline<br>soc_crew = Crew(<br>    agents=[network_analyst, web_analyst, soc_manager],<br>    tasks=[task_network, task_web, task_manager],<br>    process=Process.sequential<br>)<br><br>print(&quot;[*] Launching AI SOC Crew...\n&quot;)<br>result = soc_crew.kickoff()</pre><p>If you deploy the Docker stack and run soc_crew.py, the workflow behaves as a closed-loop system. The SOC Manager receives the correlated briefs, determines that the Shellshock payload paired with APT29 beaconing crosses the threshold for critical severity, and executes the mitigation tool. In the background, the attacker container is gracefully stopped, severing the connection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pyNlvmQXIGs8g4sw01ixJg.png" /></figure><p>Running docker ps immediately after confirms the result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SgTpjezFpKDOzgFO9YDUIw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sgAMNzrdogqVAFZ3xz9biw.png" /></figure><h3>Scaling to Production: The Reality Check</h3><p>Watching a local LLM autonomously shut down an attack is a powerful engineering exercise. However, bringing this approach — where an AI operates with a shoot-first, ask-questions-later mandate — into a professional enterprise environment is a severe operational hazard.</p><p>Granting a probabilistic model direct write-access to firewall or EDR APIs without intermediate validation is a recipe for self-inflicted outages. Consider a concrete scenario: an authorized Nessus vulnerability scanner initiates a credentialed sweep of an internal subnet at 2:00 PM on a Tuesday. The LLM misinterprets the volumetric traffic and test payloads as an active APT breach. Before anyone notices, the AI has severed the network interface of your primary CRM database. You haven’t stopped an attacker — you’ve orchestrated your own Denial of Service.</p><p>To transition this architecture from proof-of-concept to enterprise deployment, the design must incorporate deterministic guardrails.</p><h4>The SOAR Guardrail Pipeline</h4><p>Instead of the AI interacting directly with network infrastructure, its output should function as an execution trigger for a structured SOAR (Security Orchestration, Automation, and Response) playbook.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-r5TT0nb3LOhNFRahl0_yQ.png" /></figure><p>Measuring the efficiency of this pipeline requires tracking two key metrics: the <strong>False Positive Rate (FPR)</strong> of the AI’s isolation requests, and the <strong>Mean Time to Respond (MTTR)</strong> from initial detection to final enforcement.</p><h4>Human-in-the-Loop (HITL) Workflows</h4><p>For high-criticality assets, the response pipeline must rely on dynamic Human-in-the-Loop interventions. If the AI detects lateral movement targeting an isolated guest VLAN, it can safely enforce an auto-block policy. However, if the same traffic targets a core production database, the AI should stage the firewall rule and escalate to a human engineer via a ChatOps webhook — a Slack or Teams message that reads: <em>“Critical threat detected on Database_01. Do you authorize network isolation? [YES / NO]”</em></p><p>By combining the contextual reasoning of modern LLMs with strict, deterministic SOAR guardrails, security teams can fundamentally reduce the time-to-mitigation for lateral movement without compromising operational stability.</p><p>The question is no longer whether AI should actively defend our networks — it’s how much autonomy we are willing to hand over when the stakes are high.</p><p><em>If you found this guide useful, consider connecting with me on </em><a href="https://www.linkedin.com/in/jaime-garcia-escobar/"><em>LinkedIn</em></a><em> for more systems engineering and cybersecurity content.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ff1faca35d97" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bypassing vCenter’s Absolute URLs and Hardcoded WebSockets Behind a Reverse Proxy]]></title>
            <link>https://medium.com/@jaimege/fix-vcenter-sso-console-behind-reverse-proxy-c735cb1f499a?source=rss-cdc4cec79883------2</link>
            <guid isPermaLink="false">https://medium.com/p/c735cb1f499a</guid>
            <category><![CDATA[nginx]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[system-administration]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Jaime G.E.]]></dc:creator>
            <pubDate>Sun, 08 Mar 2026 17:02:49 GMT</pubDate>
            <atom:updated>2026-03-08T17:02:49.587Z</atom:updated>
            <content:encoded><![CDATA[<h3>Using NGINX as a real-time traffic sanitizer to make vSphere 7 and 8 work behind Azure App Proxy, PAM gateways, and standard reverse proxies.</h3><p>If you manage VMware environments, you’ve likely hit this wall. Your infrastructure is secured, vCenter is running perfectly, and you decide to publish it through a Reverse Proxy, Azure App Proxy, or a Privileged Access Management (PAM) gateway to enable secure remote access. You configure the public URL, open the browser, click Login, and… it fails.</p><p>The address bar suddenly exposes the private IP or internal FQDN of your vCenter (something like https://vcenter-internal.local/ui). From outside the corporate network, the connection times out. And if, by some clever workaround, you manage to fix the login loop, you immediately hit the next wall: you try to open a Virtual Machine&#39;s HTML5 console, and the screen stays completely black.</p><p>You are not alone. The VMware community has accumulated years of reports on <a href="https://communities.vmware.com/t5/VMware-vCenter-Discussions/Reverse-Proxy-for-vCenter-issues/td-p/2863406">exactly this scenario</a>. Sysadmins have been documenting the SSO redirect issue <a href="https://www.iamageekandiknow.it/2020/09/13/put-vcenter-7-0-behind-a-reverse-proxy/">since at least vCenter 6.x</a> and most existing solutions fix the login redirect but leave the <a href="https://community.broadcom.com/vmware-cloud-foundation/discussion/issue-with-websocket-connection-to-html-console-in-vmware">console black screen</a> completely unresolved.</p><p>This article explains both failure modes and shows how to fix them completely using NGINX as a real-time traffic sanitizer.</p><h3>Why Standard Proxies Fail with vCenter</h3><p>vCenter was built to run within a controlled internal network, and its SSO flow and console delivery mechanism both embed the server’s own hostname into the content they generate. Two distinct failures result from this when a proxy changes the externally visible address.</p><p><strong>The Redirect Loop.</strong> vSphere’s Single Sign-On process relies heavily on absolute redirects. When you authenticate, vCenter doesn’t redirect you to a relative path like /ui. It generates an HTTP 302 response that points your browser to its exact internally configured hostname (e.g., https://vcenter-internal.local/ui). Your browser, operating from the public internet, has no route to that address. The proxy tunnel breaks.</p><p><strong>The Black Screen.</strong> The HTML5 VM console (MKS) requires a WebSocket connection. When you launch the console, vCenter sends a JSON configuration payload to your browser that contains the WebSocket endpoint: wss://vcenter-internal.local/ticket/.... Your browser reads this payload and tries to open that connection exactly as instructed. It fails to resolve the internal hostname from the public internet and presents a permanently black screen.</p><p>The second failure is the one that trips up most partial solutions. The internal address is not in an HTTP header, it lives inside the response body, embedded in JavaScript and JSON files that a standard reverse proxy has no reason to inspect.</p><h3>The Architecture</h3><p>The solution requires placing a smart NGINX intermediary in the DMZ between vCenter and the public gateway. This NGINX instance won’t act as a conventional pass-through proxy. It will actively intercept responses from vCenter and rewrite their content before forwarding them to the client.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rpnb1xBF2Dus_jklDtVqIg.png" /></figure><p>As shown in the diagram, the sanitizer performs two distinct operations on every response:</p><p><strong>A. </strong><strong>proxy_redirect</strong> catches HTTP 302 responses and rewrites the Location header, swapping the internal hostname for the public gateway address before the client ever sees it.</p><p><strong>B. </strong><strong>sub_filter</strong> scans HTML, JavaScript, and JSON response bodies in plain text and replaces all occurrences of the internal hostname, including the hardcoded wss:// WebSocket addresses that cause the black screen.</p><h3>The Complete NGINX Configuration</h3><p>We assume your public gateway is gateway.public-domain.com:8443 and your internal vCenter is reachable at 192.168.10.50 with the FQDN vcenter-internal.local.</p><pre>worker_processes 1;<br>events { worker_connections 1024; }</pre><pre>http {<br>    include       mime.types;<br>    default_type  application/octet-stream;</pre><pre>    access_log  /var/log/nginx/access.log;<br>    error_log   /var/log/nginx/error.log warn;<br>    sendfile        on;<br>    keepalive_timeout  65;<br>    server_names_hash_bucket_size 64;<br>    server_names_hash_max_size 512;</pre><pre>    # ==========================================<br>    # NGINX PROXY FOR VCENTER (The Sanitizer)<br>    # ==========================================<br>    server {<br>        listen 443 ssl;<br>        server_name vcenter.proxy-domain.com;</pre><pre>        ssl_certificate      /etc/nginx/ssl/wildcard.crt;<br>        ssl_certificate_key  /etc/nginx/ssl/wildcard.key;<br>        ssl_protocols        TLSv1.2 TLSv1.3;<br>        ssl_prefer_server_ciphers on;</pre><pre>        location / {</pre><pre>            # ------------------------<br>            # 1. Backend vCenter Connection<br>            # ------------------------<br>            proxy_pass <a href="https://192.168.10.50;/">https://192.168.10.50;</a></pre><pre>            # SNI Spoofing: Critical to avoid 400 Bad Request<br>            proxy_ssl_name vcenter-internal.local;<br>            proxy_ssl_server_name on;<br>            proxy_ssl_verify off;</pre><pre>            # ------------------------<br>            # 2. WebSocket Tunnel Config<br>            # ------------------------<br>            proxy_http_version 1.1;<br>            proxy_set_header Upgrade $http_upgrade;<br>            proxy_set_header Connection &quot;upgrade&quot;;</pre><pre>            # Extended timeouts to keep the VM console alive<br>            proxy_read_timeout 3600s;<br>            proxy_send_timeout 3600s;</pre><pre>            # ------------------------<br>            # 3. Request Header Spoofing<br>            # ------------------------<br>            proxy_set_header Host vcenter-internal.local;<br>            proxy_set_header X-Real-IP $remote_addr;<br>            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;<br>            proxy_set_header X-Forwarded-Proto https;</pre><pre>            # Inform vCenter of the real public host<br>            proxy_set_header X-Forwarded-Host gateway.public-domain.com:8443;</pre><pre>            # DISABLE COMPRESSION so sub_filter can read the body content<br>            proxy_set_header Accept-Encoding &quot;&quot;;</pre><pre>            # ------------------------<br>            # 4. Redirect Rewrites (The Login Fix)<br>            # ------------------------<br>            proxy_redirect <a href="https://vcenter-internal.local/">https://vcenter-internal.local/</a>    <a href="https://gateway.public-domain.com:8443/;">https://gateway.public-domain.com:8443/;</a><br>            proxy_redirect <a href="https://vcenter-internal.local/ui/">https://vcenter-internal.local/ui/</a> <a href="https://gateway.public-domain.com:8443/ui/;">https://gateway.public-domain.com:8443/ui/;</a><br>            proxy_redirect <a href="http://vcenter-internal.local/">http://vcenter-internal.local/</a>     <a href="https://gateway.public-domain.com:8443/;">https://gateway.public-domain.com:8443/;</a></pre><pre>            # ------------------------<br>            # 5. Body Rewrites (The Black Screen Fix)<br>            # ------------------------<br>            # Inspect HTML, JS, and JSON where vCenter embeds its internal URLs<br>            sub_filter_types text/html text/css application/javascript text/javascript application/json;<br>            sub_filter_once off;</pre><pre>            # Rewrite standard HTTP/HTTPS links<br>            sub_filter &quot;https://vcenter-internal.local&quot; &quot;https://gateway.public-domain.com:8443&quot;;<br>            sub_filter &quot;http://vcenter-internal.local&quot;  &quot;https://gateway.public-domain.com:8443&quot;;</pre><pre>            # THE SILVER BULLET: Rewrite the hardcoded WebSocket (WSS) payload<br>            sub_filter &quot;wss://vcenter-internal.local&quot;   &quot;wss://gateway.public-domain.com:8443&quot;;<br>        }<br>    }<br>}</pre><h3>Dissecting the Magic: Why This Actually Works</h3><p>Publishing vCenter through a proxy is not just about forwarding traffic, it requires manipulating responses in both directions. Here are the specific directives that make this work where standard configurations fail.</p><p><strong>The Login Antidote (</strong><strong>proxy_redirect).</strong> When vCenter issues an HTTP 302 pointing to its private hostname, these lines intercept the Location response header and swap the internal address for the public gateway URL before it reaches the client. The browser never sees the internal address.</p><p><strong>SNI and Host Spoofing (</strong><strong>proxy_ssl_name and </strong><strong>proxy_set_header Host).</strong> vCenter&#39;s internal web server (Envoy/Tomcat) expects incoming connections to present themselves using the configured internal domain name. If NGINX passes traffic through without spoofing the Host header and the TLS SNI, vCenter aborts the SSL handshake or returns a 400 Bad Request. These two directives instruct NGINX to present itself as the expected internal client when communicating with the backend.</p><p><strong>The Black Screen Fix (</strong><strong>sub_filter &quot;wss://...&quot;).</strong> This is the silver bullet. We disable GZIP compression (Accept-Encoding &quot;&quot;) so NGINX receives the response body as readable plain text. With sub_filter_types covering application/json and application/javascript, NGINX intercepts the console configuration payload and rewrites the WebSocket address before it reaches the browser. By the time the JavaScript executes, it genuinely contains the public gateway address. The browser opens the WebSocket tunnel to the right place and the console loads.</p><p>One detail worth emphasizing: sub_filter_once off is required. vCenter&#39;s JavaScript bundles can contain the internal hostname multiple times across a single response. Without this flag, only the first occurrence gets replaced.</p><h3>Prerequisites</h3><p><strong>ngx_http_sub_module must be compiled into your NGINX build.</strong> This is the most common silent failure point. Verify it with:</p><pre>nginx -V 2&gt;&amp;1 | grep sub_filter</pre><p>If the module is missing, install nginx-extras via your package manager or recompile NGINX with the --with-http_sub_moduleflag. Without it, sub_filter directives are silently ignored and the black screen fix does nothing.</p><p><strong>Valid TLS certificates</strong> covering both your proxy domain and the public gateway domain.</p><p><strong>Network connectivity</strong> from the NGINX host to the vCenter internal IP on TCP/443.</p><p><strong>External gateway configuration.</strong> If using Azure App Proxy or a PAM gateway in front of this NGINX instance, set Translate URLs in Headers to No. NGINX owns the rewriting logic and upstream URL manipulation by the gateway will cause conflicts.</p><h3>Verifying the Fix</h3><p>Open your browser’s Developer Tools (F12) and work through both scenarios.</p><p>For the login fix, navigate to the Network tab and attempt to authenticate through the public URL. If proxy_redirect is working, no 302 responses should point to internal hostnames. All redirects should resolve within your public gateway domain.</p><p>For the console fix, once logged in, attempt to open a VM’s HTML5 console. In the Network tab, filter by WS. You should see a WebSocket request to wss://gateway.public-domain.com:8443/ticket/... return a 101 Switching Protocols status. That 101 confirms the TCP upgrade handshake completed successfully through the full proxy chain.</p><p>If the console is still black, open the Console tab and look for WebSocket errors. Connection attempts still pointing to the internal hostname indicate sub_filter is not running. The most common cause is GZIP compression not being disabled — confirm that Accept-Encoding &quot;&quot; is reaching vCenter, and verify your NGINX build includes ngx_http_sub_module.</p><h3>Important Consideration</h3><p>The sub_filter approach performs literal string replacement on the response body. It does not parse JavaScript or JSON semantically, which means it does a plain find-and-replace on whatever text NGINX receives. If a future vCenter update changes how internal hostnames appear in the console payload (through obfuscation, base64 encoding, or string concatenation across variables), the rewrite rules would need to be revisited.</p><p>Always validate this configuration against a non-production vCenter instance before rolling it out to the environment managing production workloads. The configuration above has been verified against vCenter <strong>7.0 U3</strong> and <strong>8.0 U2</strong>.</p><h3>Conclusion</h3><p>The login redirect loop and the HTML5 console black screen are two independent problems that require two independent fixes. Most partial solutions in the community address the first and leave the second open. The sub_filter body rewrite is what closes the gap — by the time the WebSocket configuration payload reaches the browser, the internal address no longer exists anywhere in it.</p><p>The result is a fully functional vCenter interface, including VM consoles, accessible through your Zero Trust gateway without modifying vCenter itself and without re-architecting the internal network.</p><p><em>If you found this guide useful, consider connecting with me on </em><a href="https://www.linkedin.com/in/jaime-garcia-escobar/"><em>LinkedIn</em></a><em> for more systems engineering and cybersecurity content.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c735cb1f499a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bypassing Hardcoded WebSocket Ports in Multi-Port Apps behind Azure App Proxy]]></title>
            <link>https://medium.com/@jaimege/bypassing-hardcoded-websocket-ports-in-multi-port-apps-behind-azure-app-proxy-043c83e231a0?source=rss-cdc4cec79883------2</link>
            <guid isPermaLink="false">https://medium.com/p/043c83e231a0</guid>
            <category><![CDATA[nginx]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[system-administration]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Jaime G.E.]]></dc:creator>
            <pubDate>Tue, 10 Feb 2026 18:56:27 GMT</pubDate>
            <atom:updated>2026-02-10T19:43:43.569Z</atom:updated>
            <content:encoded><![CDATA[<h3>Using Nginx http_sub_module to patch client-side JavaScript on the fly.</h3><p>Integrating traditional <strong>multi-port on-premise applications</strong> with modern Zero Trust architectures, like <strong>Microsoft Azure Application Proxy</strong>, often reveals architectural mismatches that are not immediately obvious during standard HTTP testing.</p><p>A specific challenge arises with legacy applications that rely on <strong>WebSockets</strong> for HTML5 RDP gateways and use <strong>hardcoded non-standard ports</strong> in their client-side JavaScript. While the main administrative interface usually works over standard HTTPS, the RDP component is often architected to enforce a connection to a specific dedicated backend port (e.g., 3389).</p><p>This “multi-port” behavior works fine in a LAN environment but breaks immediately when proxied through Azure App Proxy, which strictly enforces a single-port (443) architecture.</p><p>This article details a method to solve this connectivity issue by using Nginx not just as a reverse proxy, but as a real-time code injection layer to rewrite the WebSocket logic before it reaches the client.</p><h3>Scope and Positioning</h3><p>This approach is designed for scenarios where modifying the vendor application is not feasible and Azure Application Proxy is a deployment requirement.</p><p>While it introduces an additional processing layer, it allows legacy multi-port applications to operate within modern HTTPS-only publishing models without backend changes.</p><h3>The Architecture</h3><p>To visualize the solution, we place Nginx between the Azure Connector and the backend. Nginx acts as a “surgeon,” modifying traffic in real-time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u-AWyK75D3nAnCLYr8i3BA.png" /></figure><h3>The Problem: The Port Mismatch</h3><p>The architecture involves an Azure App Proxy connector pointing to an internal Nginx server, which acts as the SSL offloader and reverse proxy for the backend application.</p><p><strong>The Failure Scenario:</strong></p><ol><li>The user authenticates via Azure Entra ID and accesses the web portal successfully (Port 443).</li><li>The user initiates an RDP session.</li><li>The application client-side JavaScript attempts to open a WebSocket connection to wss://domain:3389.</li><li><strong>The Drop:</strong> Since the connection is explicitly requested on port 3389, Azure (or the corporate firewall) blocks the request, as only port 443 is exposed publicly.</li></ol><p>Without the ability to modify the vendor source code to use relative paths or standard ports, the connection fails silently.</p><h3>The Solution</h3><p>To resolve this, the intermediary Nginx proxy performs three critical functions:</p><ol><li><strong>Header Rewriting:</strong> Normalizes redirects to ensure the application does not expose internal hostnames.</li><li><strong>Traffic Multiplexing:</strong> Routes traffic coming into port 443 to different backend ports based on the URL path.</li><li><strong>JavaScript Injection:</strong> Uses the http_sub_module to inject a monkey-patch into the browser window.WebSocket constructor, stripping the hardcoded port from the connection string.</li></ol><h4>Why the WebSocket Override Works?</h4><p>By overriding the native window.WebSocket constructor before the application initializes its connection logic, we can intercept and normalize any hardcoded connection strings.</p><p>Since the browser resolves WebSocket URLs exactly as provided, removing the explicit port forces it to reuse the current HTTPS context (443), allowing the request to pass through Azure Application Proxy.</p><h3>Nginx Configuration</h3><p>The following configuration demonstrates how to implement the injection logic. It intercepts the HTTP response, disables compression (to allow text modification), and injects a script that overrides the WebSocket behavior.</p><pre>worker_processes 1;<br>events { worker_connections 1024; }<br><br>http {<br>    include       mime.types;<br>    default_type  application/octet-stream;<br>    <br>    server {<br>        listen 443 ssl;<br>        server_name remote-app.company.com; # Public External URL<br><br>        ssl_certificate      /etc/nginx/ssl/cert.crt;<br>        ssl_certificate_key  /etc/nginx/ssl/cert.key;<br>        ssl_protocols TLSv1.2; <br>        ssl_prefer_server_ciphers on;<br><br>        # Block 1: Main Web Interface<br>        location / {<br>            # Routes standard traffic to the main Web Interface port (e.g., 4443)<br>            proxy_pass https://backend-server.local:4443;<br><br>            # Standard Header Proxies<br>            proxy_set_header Host backend-server.local;<br>            proxy_set_header X-Real-IP $remote_addr;<br>            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;<br>            proxy_set_header X-Forwarded-Proto https;<br>            <br>            # Rewrite Redirections (Fixes Login Loop)<br>            proxy_redirect https://backend-server.local:4443/ https://remote-app.company.com/;<br>            proxy_redirect https://backend-server.local/ https://remote-app.company.com/;<br>            <br>            # INJECTION LOGIC<br>            # 1. Disable GZIP so Nginx can read/modify the response body<br>            proxy_set_header Accept-Encoding &quot;&quot;; <br>            <br>            # 2. Prevent Caching to ensure the patch is always loaded<br>            add_header Cache-Control &quot;no-store, no-cache, must-revalidate, max-age=0&quot;;<br>            expires -1;<br><br>            # 3. Configure the substitution module<br>            sub_filter_types text/html;<br>            sub_filter_once on;<br>            <br>            # 4. Inject the Patch into the &lt;head&gt;<br>            # This script intercepts the WebSocket creation and forces it to Port 443<br>            sub_filter &#39;&lt;head&gt;&#39; &#39;&lt;head&gt;<br>            &lt;script&gt;<br>                (function() {<br>                    var OriginalWebSocket = window.WebSocket;<br>                    <br>                    // Override the native WebSocket constructor<br>                    window.WebSocket = function(url, protocols) {<br>                        <br>                        // Remove hardcoded ports (e.g., 3389/4443) to force implicit HTTPS (443)<br>                        var newUrl = url.replace(&quot;:3389&quot;, &quot;&quot;).replace(&quot;:4443&quot;, &quot;&quot;);<br>                        <br>                        // Ensure the hostname matches the public Azure URL<br>                        newUrl = newUrl.replace(&quot;backend-server.local&quot;, &quot;remote-app.company.com&quot;);<br>                        newUrl = newUrl.replace(&quot;remote-app.company:3389&quot;, &quot;remote-app.company.com&quot;);<br>                        <br>                        return new OriginalWebSocket(newUrl, protocols);<br>                    };<br>                })();<br>            &lt;/script&gt;&#39;;<br>        }<br><br>        # Block 2: RDP Tunnel Routing<br>        # The script forces traffic to Port 443. Nginx identifies it via path<br>        # and routes it to the correct backend RDP port (3389).<br>        location /RDP {<br>            proxy_pass https://backend-server.local:3389;<br>            <br>            # WebSocket Upgrade Headers<br>            proxy_http_version 1.1;<br>            proxy_set_header Upgrade $http_upgrade;<br>            proxy_set_header Connection &quot;upgrade&quot;;<br>            <br>            # Backend Origin Validation<br>            # Align the Origin header with backend validation requirements<br>            proxy_set_header Host backend-server.local;<br>            proxy_set_header Origin https://backend-server.local:3389;<br>            <br>            # Extended Timeouts for Long Sessions<br>            proxy_read_timeout 3600s;<br>        }<br>    }<br>}</pre><h3>Azure App Proxy Settings</h3><p>For the WebSocket connection to succeed through Azure, specific configurations are required in the Entra ID Admin Center:</p><p><strong>Translate URLs in Headers:</strong> Set to <strong>No</strong>. Since Nginx handles the redirection logic (proxy_redirect), allowing Azure to rewrite headers can cause conflicts.</p><p><strong>Pre-Authentication:</strong> Set to <strong>Azure Active Directory</strong> to maintain security.</p><h3>Verifying the Fix</h3><p>To confirm the injection is working:</p><ol><li>Open your browser’s <strong>Developer Tools (F12)</strong>.</li><li>Navigate to the <strong>Console</strong> tab.</li><li>Initiate the RDP connection.</li><li>Look for the logs. If you see the redirection message (e.g., wss://remote-app.company.com/...), the patch is active. If the window closes immediately without logs, check if Nginx is properly stripping the Accept-Encoding header (compression often prevents sub_filter from working).</li><li>Additionally, verify in the Network tab that the WebSocket request returns a 101 Switching Protocols response. This confirms that the TCP upgrade handshake has successfully completed through the proxy chain.</li></ol><h3>Important Consideration</h3><p>Since this solution involves injecting JavaScript to override client-side behavior, it relies on the vendor keeping their variable names and WebSocket implementation consistent. Always test this configuration in a staging environment before applying application updates.</p><h3>Conclusion</h3><p>This approach decouples the external access method from the internal application logic. By manipulating the client-side code in transit, we can force multi-port applications to adhere to modern cloud port standards (HTTPS/443) without vendor support or internal code changes. This method is applicable to any web application that hardcodes ports or domains in its JavaScript frontend.</p><p><em>If you enjoyed this technical guide, consider connecting with me on </em><a href="https://www.linkedin.com/in/jaime-garcia-escobar/"><em>LinkedIn</em></a><em> for more systems engineering content.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=043c83e231a0" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>