<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title><![CDATA[Using a docker proxy in WSL]]></title>
    <link>https://linlog.skepticats.com/entries/2024/12/using-a-docker-proxy-in-wsl.php</link>
    <description><![CDATA[<p>I recently started working on a web-based project that has some non-standard networking stuff going on in the dev environment.&nbsp; The fix was easy, but took a little searching, hence this post.</p>
<p>The codebase itself is built on Node JS, but I have to run it in WSL.&nbsp; There are various build issues that keep it from building cleanly in Windows and it would be a bit of work to fix that.&nbsp; But it builds just fine under WSL, so it's easier to use that.</p>
<p>The dev setup uses a Docker container running HAProxy.&nbsp; It's set up to proxy the static portion of the website to the shared dev server (which is on the VPN) and direct the traffic for the dynamic part to a local port.&nbsp; So we have a HAProxy running in Docker, the local dev server running in WSL, and the browser running in Windows.</p>
<p>The problem: In the default WSL config, this doesn't work.&nbsp; The proxy to the shared server works just fine.&nbsp; So if I go to <code>wwwlocal.site.com</code>, that works as a proxy to <code>wwwdev.site.com</code>.&nbsp; Perfect!&nbsp; However, <code>wwwlocal.site.com/login</code> is supposed to proxy to <code>localhost:4321</code>, but that results in a 503 error.&nbsp; However, I can go directly to <code>localhost:4321</code> and it works just fine, so this is clearly a networking issue.</p>
<p>The solution was to just add a few lines to my <code>$home\.wslconfig</code> file on Windows.&nbsp; The following lines did the trick:</p>
<p><code>[wsl2]</code><br /><code>networkingMode=mirrored</code><br /><code>dnsTunneling=true</code><br /><code>autoProxy=true</code></p>
<p>You can read more about these settings <a href="https://learn.microsoft.com/en-us/windows/wsl/wsl-config">here</a>.</p>]]></description>
    <lastBuildDate>2024-12-16T15:19:55+00:00</lastBuildDate>
    <managingEditor>pageer@skepticats.com (Peter Geer)</managingEditor>
    <language>en-US</language>
    <generator>https://lnblog.skepticats.com/?v=2.3.1</generator>
  </channel>
</rss>
