{"id":30287004,"url":"https://github.com/aldotobing/nginx-log-streamer","last_synced_at":"2026-05-06T15:42:06.004Z","repository":{"id":309692880,"uuid":"1037198580","full_name":"aldotobing/nginx-log-streamer","owner":"aldotobing","description":"A high-performance WebSocket server for real-time Nginx log streaming. Stream access logs directly to web applications with minimal latency and resource overhead.","archived":false,"fork":false,"pushed_at":"2025-08-13T08:25:59.000Z","size":111,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-13T10:16:09.925Z","etag":null,"topics":["apache","http","httpd-logs","nginx","node-js","websocket"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aldotobing.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-08-13T08:00:43.000Z","updated_at":"2025-08-13T08:26:02.000Z","dependencies_parsed_at":"2025-08-13T10:17:03.680Z","dependency_job_id":"226ab665-1439-457c-923c-6161a54c660f","html_url":"https://github.com/aldotobing/nginx-log-streamer","commit_stats":null,"previous_names":["aldotobing/nginx-log-streamer"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/aldotobing/nginx-log-streamer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aldotobing%2Fnginx-log-streamer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aldotobing%2Fnginx-log-streamer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aldotobing%2Fnginx-log-streamer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aldotobing%2Fnginx-log-streamer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aldotobing","download_url":"https://codeload.github.com/aldotobing/nginx-log-streamer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aldotobing%2Fnginx-log-streamer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270775805,"owners_count":24642961,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-16T02:00:11.002Z","response_time":91,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apache","http","httpd-logs","nginx","node-js","websocket"],"created_at":"2025-08-16T21:34:58.710Z","updated_at":"2026-05-06T15:42:00.972Z","avatar_url":"https://github.com/aldotobing.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🌐 Nginx Log Streamer\n\nA high-performance WebSocket server for real-time Nginx log streaming. Stream access logs directly to web applications with minimal latency and resource overhead.\n\n\u003c!-- ![Nginx Log Streamer](nginx-log-streamer.jpg) --\u003e\n\n![Nginx Log Streamer Demo](https://img.shields.io/badge/status-active-success.svg)\n![Docker Build](https://img.shields.io/docker/cloud/build/aldotobing/nginx-log-streamer)\n![License](https://img.shields.io/badge/license-MIT-blue.svg)\n\n## ✨ Core Features\n\n- Real-time log streaming via WebSockets\n- Optional WSS (WebSocket Secure) support\n- Lightweight Node.js implementation\n- Containerized deployment with Docker\n- Seamless integration with [Nginx Log Analyzer Web UI](https://github.com/aldotobing/nginx-log-analyzer-web-ui)\n\n## 🌟 Web UI Integration\n\nThis project pairs perfectly with the [Nginx Log Analyzer Web UI](https://github.com/aldotobing/nginx-log-analyzer-web-ui) - an interactive dashboard for visualizing and analyzing your Nginx logs in real-time.\n\n### Key Features of the Web UI:\n- Real-time log visualization with interactive charts\n- Filter logs by date, IP address, request type, and more\n- Traffic analytics and performance metrics\n- User-friendly interface with dark/light themes\n- Secure WebSocket (WSS) support\n\n### How They Work Together:\n1. **Log Streamer** (this project) runs as a WebSocket server that tails your Nginx logs\n2. **Web UI** connects to the WebSocket server and displays the logs in a beautiful, interactive dashboard\n3. Together, they provide a complete solution for real-time log monitoring and analysis\n\n### Quick Start with Web UI:\n\n1. **Deploy the Log Streamer** (this project) following the instructions above\n\n2. **Set up the Web UI**\n   ```bash\n   # Clone the Web UI repository\n   git clone https://github.com/aldotobing/nginx-log-analyzer-web-ui.git\n   cd nginx-log-analyzer-web-ui\n   \n   # Install dependencies\n   npm install\n   \n   # Start the development server\n   npm run dev\n   ```\n\n3. **Configure the Web UI**\n   - Open the Web UI in your browser (default: http://localhost:3000)\n   - Go to Settings\n   - Enter your WebSocket URL (e.g., `ws://your-server-ip:1234` or `wss://your-domain.com:1234` for SSL)\n   - Save the settings\n\n4. **View Real-time Logs**\n   - The dashboard will automatically connect to your log streamer\n   - Monitor logs in real-time with interactive visualizations\n\n## ✨ Features\n\n- **Real-time Log Streaming**: Get instant updates of Nginx access logs\n- **Secure WebSocket Support**: Optional WSS (WebSocket Secure) with SSL/TLS\n- **Docker \u0026 Docker Compose Ready**: Easy deployment with containerization\n- **Lightweight**: Built with Node.js and ws for optimal performance\n- **Configurable**: Customize log file paths, ports, and number of initial lines\n\n## 🚀 Quick Start\n\n### Prerequisites\n\n- Docker and Docker Compose installed\n- Nginx installed and running\n- (Optional) SSL certificates for secure WebSocket connections\n\n### 1. Clone the Repository\n\n```bash\ngit clone https://github.com/aldotobing/nginx-log-streamer.git\ncd nginx-log-streamer\n```\n\n### 2. Configure Environment Variables\n\nCreate a `.env` file in the project root:\n\n```env\n# WebSocket server port (default: 1234)\nWS_PORT=1234\n\n# Path to Nginx access log file\nLOG_FILE_PATH=/var/log/nginx/access.log\n\n# Number of initial log lines to send on connection\nTAIL_LINES=50\n\n# Optional: SSL certificate paths (for WSS)\n# SSL_CERT_PATH=/etc/letsencrypt/live/yourdomain.com/fullchain.pem\n# SSL_KEY_PATH=/etc/letsencrypt/live/yourdomain.com/privkey.pem\n```\n\n### 3. Build and Run with Docker Compose\n\n```bash\ndocker-compose up -d --build\n```\n\n### 4. Access the WebSocket Server\n\nYour WebSocket server will be available at:\n- `ws://your-server-ip:1234` (HTTP)\n- `wss://your-domain.com:1234` (HTTPS, if SSL configured)\n\n## 🔌 Client Implementation Example\n\n### JavaScript Browser Client\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003chead\u003e\n    \u003ctitle\u003eNginx Log Viewer\u003c/title\u003e\n    \u003cstyle\u003e\n        #logs {\n            font-family: monospace;\n            white-space: pre;\n            height: 80vh;\n            overflow-y: auto;\n            background: #1e1e1e;\n            color: #f0f0f0;\n            padding: 10px;\n            border-radius: 4px;\n        }\n    \u003c/style\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n    \u003ch1\u003eNginx Access Logs\u003c/h1\u003e\n    \u003cdiv id=\"logs\"\u003e\u003c/div\u003e\n\n    \u003cscript\u003e\n        const logs = document.getElementById('logs');\n        \n        // Use wss:// for secure connections\n        const wsProtocol = window.location.protocol === 'https:' ? 'wss://' : 'ws://';\n        const ws = new WebSocket(`${wsProtocol}${window.location.hostname}:1234`);\n        \n        ws.onmessage = function(event) {\n            const logEntry = document.createElement('div');\n            logEntry.textContent = event.data;\n            logs.prepend(logEntry);\n            \n            // Keep only the last 1000 log entries\n            while (logs.children.length \u003e 1000) {\n                logs.removeChild(logs.lastChild);\n            }\n        };\n        \n        // Send periodic pings to keep connection alive\n        setInterval(() =\u003e {\n            if (ws.readyState === WebSocket.OPEN) {\n                ws.send(JSON.stringify({ type: 'ping' }));\n            }\n        }, 30000);\n        \n        ws.onclose = function() {\n            logs.prepend('Connection closed. Attempting to reconnect...');\n            setTimeout(() =\u003e window.location.reload(), 5000);\n        };\n    \u003c/script\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n## 🔧 Configuration Options\n\n### Environment Variables\n\n| Variable | Required | Default | Description |\n|----------|----------|---------|-------------|\n| `WS_PORT` | No | `1234` | Port for WebSocket server |\n| `LOG_FILE_PATH` | Yes | - | Path to Nginx access log file |\n| `TAIL_LINES` | No | `50` | Number of initial log lines to send |\n| `SSL_CERT_PATH` | No | - | Path to SSL certificate file |\n| `SSL_KEY_PATH` | No | - | Path to SSL private key file |\n\n### Nginx Configuration (Reverse Proxy)\n\nFor production use, it's recommended to set up Nginx as a reverse proxy:\n\n```nginx\nserver {\n    listen 80;\n    server_name your-domain.com;\n    \n    # Redirect HTTP to HTTPS\n    return 301 https://$host$request_uri;\n}\n\nserver {\n    listen 443 ssl http2;\n    server_name your-domain.com;\n    \n    # SSL configuration\n    ssl_certificate /etc/letsencrypt/live/your-domain.com/fullchain.pem;\n    ssl_certificate_key /etc/letsencrypt/live/your-domain.com/privkey.pem;\n    \n    # WebSocket proxy\n    location /ws/ {\n        proxy_pass http://localhost:1234;\n        proxy_http_version 1.1;\n        proxy_set_header Upgrade $http_upgrade;\n        proxy_set_header Connection \"upgrade\";\n        proxy_set_header Host $host;\n        proxy_set_header X-Real-IP $remote_addr;\n        proxy_read_timeout 1d;\n    }\n    \n    # Serve the HTML client\n    location / {\n        root /path/to/your/html/client;\n        try_files $uri /index.html;\n    }\n}\n```\n\n## 🛠 Development\n\n### Local Development\n\n1. Install dependencies:\n   ```bash\n   npm install\n   ```\n\n2. Start the server:\n   ```bash\n   WS_PORT=1234 LOG_FILE_PATH=/var/log/nginx/access.log TAIL_LINES=50 node server.js\n   ```\n\n### Building the Docker Image\n\n```bash\ndocker build -t nginx-log-streamer .\n```\n\n### Running Tests\n\n```bash\n# Coming soon\n# npm test\n```\n\n## 📦 Deployment\n\n### Direct Docker Deployment with SSL\n\nYou can run the container directly with Docker using your own SSL certificates without needing an Nginx reverse proxy:\n\n```bash\n# Build the image\ndocker build -t yourusername/nginx-log-streamer:latest .\n\n# Run the container with SSL support\ndocker run -d \\\n  --name nginx-log-streamer \\\n  --restart always \\\n  -e WS_PORT=1234 \\\n  -e LOG_FILE_PATH=/var/log/nginx/access.log \\\n  -e TAIL_LINES=50 \\\n  -e SSL_CERT_PATH=/etc/letsencrypt/live/your-domain.com/fullchain.pem \\\n  -e SSL_KEY_PATH=/etc/letsencrypt/live/your-domain.com/privkey.pem \\\n  -v /var/log/nginx:/var/log/nginx:ro \\\n  -v /etc/letsencrypt:/etc/letsencrypt:ro \\\n  -p 1234:1234 \\\n  yourusername/nginx-log-streamer:latest\n```\n\n**Note:**\n- Replace `your-domain.com` with your actual domain name\n- Ensure the SSL certificate files exist at the specified paths\n- The container needs read access to both the Nginx logs and SSL certificates\n- The `--restart always` flag ensures the container restarts automatically if it stops\n\n### Kubernetes\n\nExample deployment configuration:\n\n```yaml\napiVersion: apps/v1\nkind: Deployment\nmetadata:\n  name: nginx-log-streamer\nspec:\n  replicas: 1\n  selector:\n    matchLabels:\n      app: nginx-log-streamer\n  template:\n    metadata:\n      labels:\n        app: nginx-log-streamer\n    spec:\n      containers:\n      - name: nginx-log-streamer\n        image: yourusername/nginx-log-streamer:latest\n        ports:\n        - containerPort: 1234\n        env:\n        - name: WS_PORT\n          value: \"1234\"\n        - name: LOG_FILE_PATH\n          value: \"/var/log/nginx/access.log\"\n        - name: TAIL_LINES\n          value: \"50\"\n        volumeMounts:\n        - name: nginx-logs\n          mountPath: /var/log/nginx\n          readOnly: true\n      volumes:\n      - name: nginx-logs\n        hostPath:\n          path: /var/log/nginx\n          type: Directory\n```\n\n## 🔒 Security Considerations\n\n1. **Use HTTPS/WSS**: Always use secure WebSocket connections in production.\n2. **Authentication**: Implement authentication if exposing the WebSocket endpoint to the internet.\n3. **Rate Limiting**: Consider implementing rate limiting to prevent abuse.\n4. **Log Rotation**: Ensure proper log rotation is configured for Nginx.\n\n## 📝 License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## 🙏 Acknowledgments\n\n- Built with [Node.js](https://nodejs.org/) and [ws](https://github.com/websockets/ws)\n- Inspired by the need for real-time log monitoring\n- Special thanks to all contributors\n\n## 🤝 Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n1. Fork the Project\n2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)\n3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)\n4. Push to the Branch (`git push origin feature/AmazingFeature`)\n5. Open a Pull Request\n\n## 📧 Contact\n\nAldo Tobing - [@aldo_tobing](https://twitter.com/aldo_tobing) \n\nProject Link: [https://github.com/aldotobing/nginx-log-streamer](https://github.com/aldotobing/nginx-log-streamer)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faldotobing%2Fnginx-log-streamer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faldotobing%2Fnginx-log-streamer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faldotobing%2Fnginx-log-streamer/lists"}