Upload 2 files
Browse files- Dockerfile +19 -0
- proxy.js +40 -0
Dockerfile
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM tsaridas/stremio-docker:latest
|
| 2 |
+
|
| 3 |
+
# Install Node.js for our proxy
|
| 4 |
+
RUN apk add --no-cache nodejs npm
|
| 5 |
+
|
| 6 |
+
# Create a simple proxy server
|
| 7 |
+
WORKDIR /app
|
| 8 |
+
COPY proxy.js .
|
| 9 |
+
|
| 10 |
+
# Set environment variables for Stremio
|
| 11 |
+
ENV NO_CORS=1
|
| 12 |
+
ENV CASTING_DISABLED=1
|
| 13 |
+
ENV DISABLE_CACHING=1
|
| 14 |
+
|
| 15 |
+
# Expose HF Spaces port
|
| 16 |
+
EXPOSE 7860
|
| 17 |
+
|
| 18 |
+
# Start both Stremio and the proxy
|
| 19 |
+
CMD ["/bin/sh", "-c", "(/app/stremio-web-service-run.sh &) && node /app/proxy.js"]
|
proxy.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const http = require('http');
|
| 2 |
+
|
| 3 |
+
const TARGET_PORT = 11470;
|
| 4 |
+
const LISTEN_PORT = 7860;
|
| 5 |
+
|
| 6 |
+
// Create a proxy server
|
| 7 |
+
const proxy = http.createServer((clientReq, clientRes) => {
|
| 8 |
+
console.log(`Proxying request to: ${clientReq.url}`);
|
| 9 |
+
|
| 10 |
+
// Configure the request options
|
| 11 |
+
const options = {
|
| 12 |
+
hostname: 'localhost',
|
| 13 |
+
port: TARGET_PORT,
|
| 14 |
+
path: clientReq.url,
|
| 15 |
+
method: clientReq.method,
|
| 16 |
+
headers: clientReq.headers
|
| 17 |
+
};
|
| 18 |
+
|
| 19 |
+
// Create the proxied request
|
| 20 |
+
const proxyReq = http.request(options, (proxyRes) => {
|
| 21 |
+
clientRes.writeHead(proxyRes.statusCode, proxyRes.headers);
|
| 22 |
+
proxyRes.pipe(clientRes, { end: true });
|
| 23 |
+
});
|
| 24 |
+
|
| 25 |
+
// Handle errors
|
| 26 |
+
proxyReq.on('error', (err) => {
|
| 27 |
+
console.error('Proxy error:', err);
|
| 28 |
+
clientRes.writeHead(500);
|
| 29 |
+
clientRes.end('Proxy error connecting to Stremio server');
|
| 30 |
+
});
|
| 31 |
+
|
| 32 |
+
// Pipe the client request to the proxy request
|
| 33 |
+
clientReq.pipe(proxyReq, { end: true });
|
| 34 |
+
});
|
| 35 |
+
|
| 36 |
+
// Start the proxy server
|
| 37 |
+
proxy.listen(LISTEN_PORT, () => {
|
| 38 |
+
console.log(`Proxy server running on port ${LISTEN_PORT}`);
|
| 39 |
+
console.log(`Forwarding to Stremio server on port ${TARGET_PORT}`);
|
| 40 |
+
});
|