[GH-ISSUE #701] SSL support #62360

Closed
opened 2026-05-03 08:25:18 -05:00 by GiteaMirror · 4 comments
Owner

Originally created by @ivanfioravanti on GitHub (Oct 4, 2023).
Original GitHub issue: https://github.com/ollama/ollama/issues/701

Hi super Ollama team!
I received an interest comment on the chatbot-ollama interface here.
It seems that sharing a server and connect from multiple clients works, but it's plain HTTP.
Adding SSL can help in this scenario.

Originally created by @ivanfioravanti on GitHub (Oct 4, 2023). Original GitHub issue: https://github.com/ollama/ollama/issues/701 Hi super Ollama team! I received an interest comment on the chatbot-ollama interface [here](https://github.com/ivanfioravanti/chatbot-ollama/issues/4). It seems that sharing a server and connect from multiple clients works, but it's plain HTTP. Adding SSL can help in this scenario.
GiteaMirror added the feature request label 2026-05-03 08:25:18 -05:00
Author
Owner

@ivanfioravanti commented on GitHub (Oct 4, 2023):

Clearly there is always the easy way to have something in front of Ollama, but I was just wondering if this can make sense

<!-- gh-comment-id:1747551055 --> @ivanfioravanti commented on GitHub (Oct 4, 2023): Clearly there is always the easy way to have something in front of Ollama, but I was just wondering if this can make sense
Author
Owner

@montoulieu commented on GitHub (Oct 5, 2023):

Yeah +1.
SSL support would be a great addition.

<!-- gh-comment-id:1749518961 --> @montoulieu commented on GitHub (Oct 5, 2023): Yeah +1. SSL support would be a great addition.
Author
Owner

@Clivern commented on GitHub (Oct 5, 2023):

It uses gin so RunTLS can be used I think
https://github.com/gin-gonic/gin/blob/master/docs/doc.md?plain=1#L2032-L2051

<!-- gh-comment-id:1749754059 --> @Clivern commented on GitHub (Oct 5, 2023): It uses gin so `RunTLS` can be used I think https://github.com/gin-gonic/gin/blob/master/docs/doc.md?plain=1#L2032-L2051
Author
Owner

@thesourmango commented on GitHub (Nov 1, 2023):

Had the same issue and found this thread. I'm not familiar with gin and RunTLS so I used an express server as middleware. Thought I could share the server file since it's so dead simple someone might have use of it :)

On the front-end I call the middleware express server on https://yourdomain.com/api/
const res = await fetch("https://yourdomain.com/api/", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ "question": query })
});

On the middleware express API I get the response via https, i forward it to ollama as http and return the response as https. No more browser complaints ;)

Heres the code for the middleware API
const express = require("express");
const https = require("https");
const fs = require("fs");
const path = require("path");

const app = express();
const port = 443;
app.use(express.static('public')) // For serving static files from public folder.
app.use(express.json()); // For parsing application/json

// Routes
app.post("/api/", async (req, res) => {
// Send message to Model API
const response = await fetch("http://localhost:11434/api/generate", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ "model": "zephyr", "prompt": req.body.question})
});
// Return stream of Uint8Array
for await (const chunk of response.body) {
res.write(chunk); // took me ages to find this oh so obvious method!
}

});

// Read SSL certificate and key files
const options = {
// Replace these with location of servers certificates
key: fs.readFileSync("./privkey.pem"),
cert: fs.readFileSync("./fullchain.pem"),
};

// Create HTTPS server
const server = https.createServer(options, app);

server.listen(port, () => {
console.log(App listening on https://localhost:${port});
});

<!-- gh-comment-id:1788504409 --> @thesourmango commented on GitHub (Nov 1, 2023): Had the same issue and found this thread. I'm not familiar with gin and RunTLS so I used an express server as middleware. Thought I could share the server file since it's so dead simple someone might have use of it :) On the front-end I call the middleware express server on https://yourdomain.com/api/ const res = await fetch("https://yourdomain.com/api/", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ "question": query }) }); On the middleware express API I get the response via https, i forward it to ollama as http and return the response as https. No more browser complaints ;) Heres the code for the middleware API const express = require("express"); const https = require("https"); const fs = require("fs"); const path = require("path"); const app = express(); const port = 443; app.use(express.static('public')) // For serving static files from public folder. app.use(express.json()); // For parsing application/json // Routes app.post("/api/", async (req, res) => { // Send message to Model API const response = await fetch("http://localhost:11434/api/generate", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ "model": "zephyr", "prompt": req.body.question}) }); // Return stream of Uint8Array for await (const chunk of response.body) { res.write(chunk); // took me ages to find this oh so obvious method! } }); // Read SSL certificate and key files const options = { // Replace these with location of servers certificates key: fs.readFileSync("./privkey.pem"), cert: fs.readFileSync("./fullchain.pem"), }; // Create HTTPS server const server = https.createServer(options, app); server.listen(port, () => { console.log(`App listening on https://localhost:${port}`); });
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#62360