35 lines
1.3 KiB
JavaScript
35 lines
1.3 KiB
JavaScript
const express = require('express');
|
|
const path = require('path');
|
|
const http = require('http'); // Changed from https to http
|
|
const app = express();
|
|
const port = 3000; // This is the port your container listens on internally
|
|
|
|
// --- SSL/TLS Certificate code removed ---
|
|
// Nginx Proxy Manager handles HTTPS, so the app only needs to listen for HTTP.
|
|
|
|
// Serve static files from the current directory (which is /usr/src/app due to volume mapping)
|
|
app.use(express.static(path.join(__dirname)));
|
|
|
|
// Route for the root URL, serving index.html
|
|
app.get('/', (req, res) => {
|
|
res.sendFile(path.join(__dirname, 'index.html'), (err) => {
|
|
if (err) {
|
|
console.error('Error sending index.html:', err);
|
|
res.status(404).send('File not found or other server error.');
|
|
}
|
|
});
|
|
});
|
|
|
|
// Create an HTTP server using the Express app
|
|
const httpServer = http.createServer(app);
|
|
|
|
// Start the HTTP server on the internal container port (3000)
|
|
httpServer.listen(port, () => {
|
|
console.log(`HTTP Server running on port ${port} inside the container.`);
|
|
console.log(`Access this via Nginx Proxy Manager at https://apps.aglink.duckdns.org/`);
|
|
});
|
|
|
|
// Optional: Implement a handler to trust proxies (like Nginx)
|
|
// to correctly identify the client IP, though often not strictly necessary for simple routing.
|
|
// app.set('trust proxy', 1);
|