mirror of
https://github.com/DeNNiiInc/Connect-5.git
synced 2026-04-18 00:56:00 +00:00
- Created apache-config.conf with proxy rules - Added APACHE_FIX.md with step-by-step instructions - Fixes 404 errors on /api and /socket.io endpoints - Enables WebSocket support for multiplayer
119 lines
2.5 KiB
Markdown
119 lines
2.5 KiB
Markdown
# Quick Fix for CloudSticks Apache Proxy
|
|
|
|
## Problem
|
|
The Node.js server is running on port 3000, but Apache is not forwarding `/api` and `/socket.io` requests to it.
|
|
|
|
## Solution
|
|
|
|
### Step 1: Enable Apache Proxy Modules
|
|
|
|
Run these commands on your CloudSticks server:
|
|
|
|
```bash
|
|
sudo a2enmod proxy
|
|
sudo a2enmod proxy_http
|
|
sudo a2enmod proxy_wstunnel
|
|
sudo a2enmod rewrite
|
|
```
|
|
|
|
### Step 2: Find Your Apache Config File
|
|
|
|
CloudSticks likely uses one of these locations:
|
|
```bash
|
|
# Check which file exists:
|
|
ls -la /etc/apache2/sites-available/connect5*
|
|
ls -la /etc/apache2/sites-available/000-default-le-ssl.conf
|
|
ls -la /etc/apache2/sites-available/default-ssl.conf
|
|
```
|
|
|
|
### Step 3: Edit the Config File
|
|
|
|
```bash
|
|
# Use nano or vi to edit (replace with your actual file):
|
|
sudo nano /etc/apache2/sites-available/connect5.conf
|
|
```
|
|
|
|
### Step 4: Add These Lines
|
|
|
|
Add these lines **inside** your `<VirtualHost *:443>` block (before `</VirtualHost>`):
|
|
|
|
```apache
|
|
# Proxy API and Socket.io to Node.js
|
|
ProxyPreserveHost On
|
|
ProxyPass /api http://localhost:3000/api
|
|
ProxyPassReverse /api http://localhost:3000/api
|
|
ProxyPass /socket.io http://localhost:3000/socket.io
|
|
ProxyPassReverse /socket.io http://localhost:3000/socket.io
|
|
|
|
# WebSocket support
|
|
RewriteEngine On
|
|
RewriteCond %{HTTP:Upgrade} =websocket [NC]
|
|
RewriteRule /(.*) ws://localhost:3000/$1 [P,L]
|
|
```
|
|
|
|
### Step 5: Test and Restart Apache
|
|
|
|
```bash
|
|
# Test configuration
|
|
sudo apache2ctl configtest
|
|
|
|
# If OK, restart Apache
|
|
sudo systemctl restart apache2
|
|
```
|
|
|
|
### Step 6: Verify It Works
|
|
|
|
```bash
|
|
# Test API endpoint
|
|
curl https://connect5.beyondcloud.technology/api/db-status
|
|
|
|
# Should return JSON with "connected": true
|
|
```
|
|
|
|
Then visit https://connect5.beyondcloud.technology/ in your browser!
|
|
|
|
---
|
|
|
|
## Alternative: Quick .htaccess Method
|
|
|
|
If you can't edit the Apache config, try adding this to `.htaccess` in your project root:
|
|
|
|
```apache
|
|
RewriteEngine On
|
|
|
|
# Proxy API requests
|
|
RewriteCond %{REQUEST_URI} ^/api/
|
|
RewriteRule ^api/(.*)$ http://localhost:3000/api/$1 [P,L]
|
|
|
|
# Proxy Socket.io requests
|
|
RewriteCond %{REQUEST_URI} ^/socket\.io/
|
|
RewriteRule ^socket\.io/(.*)$ http://localhost:3000/socket.io/$1 [P,L]
|
|
```
|
|
|
|
**Note**: This requires `AllowOverride All` in your Apache config.
|
|
|
|
---
|
|
|
|
## Troubleshooting
|
|
|
|
### Check if Node.js is Running
|
|
```bash
|
|
ps aux | grep "node server.js"
|
|
curl http://localhost:3000/api/db-status
|
|
```
|
|
|
|
### Check Apache Error Logs
|
|
```bash
|
|
sudo tail -f /var/log/apache2/error.log
|
|
```
|
|
|
|
### Check if Modules are Enabled
|
|
```bash
|
|
apache2ctl -M | grep proxy
|
|
```
|
|
|
|
Should show:
|
|
- proxy_module
|
|
- proxy_http_module
|
|
- proxy_wstunnel_module
|