PREDICTIVE TREND INSIGHT
Best frameworks to run local models inside rigid old corporate firewalls Illustration

Best frameworks to run local models inside rigid old corporate firewalls

Direct Summary:

To run local models like Ollama behind a locked-down corporate firewall, pull model weights on an internet-connected machine, copy them into the OLLAMA_MODELS directory on the restricted machine, and route the runtime's own outbound HTTPS calls through the corporate proxy with HTTPS_PROXY — trusting the proxy's TLS-inspection certificate at the OS level so pulls and updates don't fail on handshake errors.

"Good tools make the craft invisible."

— Unknown

Key Insights

  • Offline Model Transfer: Pull weights on a connected machine, then copy the OLLAMA_MODELS directory to the restricted host instead of relying on a direct network pull.
  • Proxy Routing: Set HTTPS_PROXY (not HTTP_PROXY) so the runtime's outbound calls go through the corporate proxy the way the firewall expects.
  • TLS Trust: If the corporate proxy does TLS inspection, its CA certificate must be trusted at the OS level or every HTTPS pull fails on a handshake error.

"Rigid old corporate firewalls" usually means two things at once: outbound traffic only leaves through a monitored HTTP(S) proxy with a TLS-inspecting certificate, and nobody is installing new software or opening new ports without a change request. A local model runner has to work within both constraints — it isn't just about running inference offline, it's about getting the runtime installed and its (occasional) network calls routed through infrastructure the security team already controls.

The Two Real Problems

1. Getting model weights in. Runtimes like Ollama pull models directly from the internet by default, which a locked-down network won't allow. The practical fix is a two-machine handoff: pull the model on a machine that has internet access, then copy the model files to the restricted machine.

2. Routing the runtime's own traffic through the corporate proxy. Even "local" runners phone home occasionally (update checks, optional cloud features) unless told not to, and if your workflow does call an external API for anything, it needs to go through the proxy your firewall expects — with the proxy's own TLS certificate trusted, or every HTTPS connection fails with a certificate error.

firewall_setup.sh
# 1. On a machine WITH internet access: pull the model normally
ollama pull llama3.1:8b

# Ollama stores models on disk in a plain directory, not inside a container -
# find the location with:
echo $OLLAMA_MODELS   # defaults to ~/.ollama/models (macOS/Linux)

# Copy that whole directory to the restricted machine (USB, internal file share, etc.)
# then point Ollama at it there:
export OLLAMA_MODELS=/path/to/copied/models

# 2. Route Ollama's own outbound calls through the corporate proxy.
# Ollama only pulls over HTTPS, so only set HTTPS_PROXY - setting HTTP_PROXY
# too can interrupt the client's own connection to the local server.
export HTTPS_PROXY=https://proxy.internal.example.com:8080

# If the proxy does TLS inspection (most enterprise proxies do), the proxy's
# own CA certificate has to be trusted by the OS, or every pull will fail
# with a TLS handshake error - this is not an Ollama-specific step.
Environment Variable Purpose Notes
OLLAMA_MODELS Points Ollama at a model directory that isn't the default Used to load models copied in manually, without a network pull
HTTPS_PROXY Routes Ollama's outbound HTTPS calls through a corporate proxy Ollama's own docs say to avoid also setting HTTP_PROXY, since it only pulls over HTTPS and that variable can interrupt local client connections

None of this is exotic — it's the same "get the artifact past the perimeter, then get the runtime talking through the approved egress path" pattern IT teams already apply to any new piece of self-hosted software. The main thing that trips people up is assuming a "local" AI tool has zero network dependencies; in practice the model weights and the runtime binary both cross the perimeter at some point, so it's worth planning both.

Practical Challenge

On a machine with internet access, run ollama pull for a small model, locate the resulting files under your OLLAMA_MODELS directory, and confirm you can copy that directory to a second location and point a fresh Ollama instance at it with the environment variable — without any network pull happening on the second instance.

Concept Check

Why should you set HTTPS_PROXY but avoid setting HTTP_PROXY when running Ollama behind a corporate proxy?
Correct! Per Ollama's own FAQ, model pulls only happen over HTTPS, and setting HTTP_PROXY as well can interfere with the client-to-server connection on localhost.
Incorrect. Try again! Hint: Ollama's documentation specifically warns that HTTP_PROXY can interrupt client connections to the local server, since pulls only ever use HTTPS.

Sources & Further Reading

  • Ollama FAQ — Official Docs — covers the HTTPS_PROXY/HTTP_PROXY distinction, custom CA certificates for TLS-inspecting proxies, and the default OLLAMA_MODELS storage locations per OS, cited directly for the commands in this lesson.
Previous Guide Dashboard Next Guide