drdread
  • drdread
  • 100% (Exalted)
  • Advanced Member Topic Starter
a month ago
With all of the new visual studio plug-ins now available, how feasible is it to host OLLama on IIS as a public resource for our company?
Sponsor

Want to thank us? Use: Patreon or PayPal or Bitcoins: bc1q4whppe29dw77rm4kv4pln0gqae4yjnxly0dny0hky6yhnafukzjsyrsqhk

All opinions expressed within these pages are sent in by members of the public or by our staff in their spare time, and as such do not represent any opinion held by sircles.net Ltd or their partners.


sirclesadmin
a month ago
Yes, you can run OLLama on a Windows Server and make it accessible as a public resource for clients. While OLLama is designed to run locally and serve models through an API, setting it up on IIS (Internet Information Services) is possible with some configuration.
Steps to Set Up OLLama on a Windows Server:

Install OLLama on Windows Server
Download and install OLLama for Windows from OLLama’s website.
Open a terminal (PowerShell or Command Prompt) and verify it works by running:ollama run mistral
(Replace "mistral" with the model you plan to use)


Run OLLama’s API Server
OLLama provides an API by default. You can start the server manually:ollama serve
By default, it listens on localhost:11434.


Enable External Access
By default, OLLama binds only to localhost. To allow external access:ollama serve --host 0.0.0.0
You might need to configure Windows Firewall to allow traffic on port 11434.

Set Up a Reverse Proxy on IIS
Install IIS (if not already installed)
Enable URL Rewrite and Application Request Routing (ARR)
Open IIS Manager → Select your server
Install URL Rewrite and ARR from the Microsoft IIS extensions site.

Create a New Site or Bind to an Existing One
Set up a new site in IIS or use an existing one.
Point it to a folder with a minimal web app (if needed).

Configure a Reverse Proxy to OLLama
In IIS Manager, select the site and open URL Rewrite.
Create a new rule:
Match URL: *
Conditions: None
Action:
Action Type: Rewrite
Rewrite URL: http://localhost:11434/{R:1}
Preserve Host Headers: Yes
Apply the rule.

Secure the Public API
Since OLLama does not have built-in authentication, you should:
Enable HTTPS on IIS
Restrict API Access (e.g., IP whitelisting, API key middleware)
Use a Firewall or WAF to prevent abuse

Test the Setup
Access OLLama’s API externally via your domain or public IP:curl -X POST "https://yourdomain.com/api/generate" -H "Content-Type: application/json" -d '{ "model": "mistral", "prompt": "Hello, world!" }'

Alternative Approach (Without IIS)
Instead of IIS, you can also use Nginx or a lightweight FastAPI/Flask wrapper if IIS adds unnecessary complexity.
Would you like help with setting up any specific step?

drdread
  • drdread
  • 100% (Exalted)
  • Advanced Member Topic Starter
a month ago
Step 1: Install OLLama on Windows Server
Download and Install OLLama for Windows

Visit OLLama's website and download the Windows installer.
Run the installer and follow the prompts.
Verify the Installation

Open PowerShell or Command Prompt and run:
ollama run mistral
If the model loads and responds, the installation is successful.
If you need another model, you can install it by running:
ollama pull llama3
Step 2: Start OLLama's API Server
OLLama includes a built-in API that listens on localhost:11434.

Start the API Server:

ollama serve
This runs OLLama in API mode on localhost:11434.
Allow External Access (Required for IIS or public access):

By default, OLLama only listens on localhost, meaning no external devices can connect.
To change this, run:
ollama serve --host 0.0.0.0
This allows OLLama to be accessed from other devices.
Step 3: Configure Windows Firewall to Allow Traffic
Since we opened OLLama’s API to external access, we need to allow inbound traffic on port 11434.

Open Windows Defender Firewall

Press Win + R, type wf.msc, and hit Enter.
Click on Inbound Rules → New Rule.
Create a New Rule

Rule Type: Port
Protocol: TCP
Port: 11434
Action: Allow the connection
Profile: Select all profiles (Domain, Private, Public)
Name: OLLama API
Click Finish.

Step 4: Install and Configure IIS (Internet Information Services)
We will set up IIS as a reverse proxy to OLLama so clients can access it via an easy-to-use domain or IP.

1. Install IIS on Windows Server
Open PowerShell (Admin) and run:
Install-WindowsFeature -name Web-Server -IncludeManagementTools
After installation, restart the server.
2. Enable Required IIS Features
IIS needs Application Request Routing (ARR) and URL Rewrite to act as a proxy.

Open IIS Manager (inetmgr).
Select the server (left panel).
Click Manage Server → Get New Web Platform Components.
Install:
Application Request Routing (ARR)
URL Rewrite
Step 5: Set Up a Reverse Proxy on IIS
Now, we configure IIS to forward incoming requests to OLLama.

1. Create a New Site in IIS
Open IIS Manager.
Right-click Sites → Add Website.
Site name: OLLamaAPI
Physical path: C:\inetpub\wwwroot
Binding: http | Port: 80 (or 443 for HTTPS)
Click OK.
2. Configure Reverse Proxy in IIS
Select the new site (OLLamaAPI).
Open URL Rewrite.
Click Add Rules...
Choose Reverse Proxy (if available) or create a custom rewrite rule:
Requested URL: *
Conditions: None
Action Type: Rewrite
Rewrite URL: http://localhost:11434/{R:1}
Preserve Host Headers: Yes
Apply and restart IIS.
Step 6: Secure the API (Optional but Recommended)
Since this will be a public API, we should add security measures.

Enable HTTPS (SSL)

Use Let’s Encrypt or a commercial SSL certificate.
Add HTTPS binding in IIS Manager → Sites → OLLamaAPI.
Restrict Access by IP

Use IIS IP Restrictions to allow only certain clients.
Add Authentication

You can add Basic Authentication in IIS or implement API key authentication.
Step 7: Test External Access
From another machine, try:
curl -X POST "http://yourserver.com/api/generate" -H "Content-Type: application/json" -d '{ "model": "mistral", "prompt": "Hello, world!" }'
If it responds, your setup is complete!