@ -157,15 +157,23 @@ sudo systemctl restart apache2
@@ -157,15 +157,23 @@ sudo systemctl restart apache2
ServerAlias www.jumble.imwald.eu
# Reverse Proxy Configuration
ProxyPreserveHost On
# Proxy for the jumble-proxy-server (must come BEFORE the catch-all / rule)
# The code constructs: ${proxyServer}/sites/${encodeURIComponent(url)}
# So /proxy/sites/... needs to be forwarded to http://127.0.0.1:8090/sites/...
ProxyPass /proxy/ http://127.0.0.1:8090/
ProxyPassReverse /proxy/ http://127.0.0.1:8090/
# Reverse Proxy for the main Jumble app
# IMPORTANT: Use Location block to scope headers properly for /proxy/ path only
< Location / proxy / >
ProxyPreserveHost Off
ProxyPass http://127.0.0.1:8090/
ProxyPassReverse http://127.0.0.1:8090/
# Unset forwarded headers that might make the proxy server use Host header instead of URL path
RequestHeader unset X-Forwarded-Host
RequestHeader unset X-Forwarded-Server
RequestHeader set Host "127.0.0.1:8090"
< / Location >
# Reverse Proxy for the main Jumble app (needs Host header preserved)
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:32768/
ProxyPassReverse / http://127.0.0.1:32768/
@ -196,10 +204,32 @@ sudo systemctl reload apache2
@@ -196,10 +204,32 @@ sudo systemctl reload apache2
5. **Test the proxy route:**
```bash
# Test with a real URL - the code constructs /proxy/sites/{encoded-url}
curl -I https://jumble.imwald.eu/proxy/sites/https%3A%2F%2Fexample.com
# Should return 200 OK if working correctly
curl https://jumble.imwald.eu/proxy/sites/https%3A%2F%2Fexample.com
# Should return example.com's HTML, NOT jumble.imwald.eu's HTML
# If you see Jumble HTML, the proxy server is using the Host header instead of the URL path
```
**If the test returns Jumble HTML instead of the requested site's HTML:**
The proxy server is using the `Host` header (`jumble.imwald.eu`) to determine what to fetch. Update your Apache config to use `ProxyPreserveHost Off` for the `/proxy/` path:
```apache
# In your Apache config, change from:
ProxyPreserveHost On
ProxyPass /proxy/ http://127.0.0.1:8090/
# To:
ProxyPreserveHost Off
ProxyPass /proxy/ http://127.0.0.1:8090/
ProxyPassReverse /proxy/ http://127.0.0.1:8090/
# Then set it back to On for the main app:
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:32768/
```
Then reload Apache and test again.
6. **Build with the proxy URL:**
```bash
docker build \
@ -220,6 +250,147 @@ docker build \
@@ -220,6 +250,147 @@ docker build \
## Troubleshooting
### If Proxy Returns Jumble HTML Instead of Requested Site
If you've set `ProxyPreserveHost Off` but still get Jumble HTML, test the proxy server directly:
**1. Test the proxy server directly (bypassing Apache):**
```bash
# Test direct connection to proxy on port 8090
curl http://127.0.0.1:8090/sites/https%3A%2F%2Fexample.com
# Should return example.com's HTML, NOT jumble.imwald.eu's HTML
```
**2. Check proxy server logs:**
```bash
docker logs imwald-jumble-proxy --tail 50
# Look for what URL the proxy is trying to fetch
# This will show if the proxy server is receiving the correct path or if it's using Host header
```
**2b. Check what request the proxy server is actually receiving:**
```bash
# Enable verbose logging in Apache to see what it's forwarding
# Or check what the proxy receives by making a test request and watching logs:
docker logs -f imwald-jumble-proxy &
# Then in another terminal:
curl -v https://jumble.imwald.eu/proxy/sites/https%3A%2F%2Fexample.com
# Look at the proxy logs to see what URL it tried to fetch
```
**3. Check if Apache is receiving `/proxy/` requests:**
```bash
# Watch Apache access log to see if /proxy/ requests reach Apache
sudo tail -f /var/log/apache2/access.log | grep proxy
# Then in another terminal, make a request:
curl https://jumble.imwald.eu/proxy/sites/https%3A%2F%2Fexample.com
# Check if the request appears in Apache logs
```
**3b. Check what Apache is forwarding:**
```bash
# Check Apache error log for proxy-related entries
sudo tail -f /var/log/apache2/error.log
# Then make a request and see what Apache is doing
```
**3c. Verify Apache config is being used:**
```bash
# Check that your Location block syntax is correct:
sudo apache2ctl -S | grep jumble.imwald.eu
# Make sure the site is enabled and config syntax is correct:
sudo apache2ctl configtest
```
**4. Possible Issues:**
**IMPORTANT: If you see `Server: nginx` in response headers, nginx is in front of Apache!**
If you see `Server: nginx/1.29.3` or `X-Powered-By: PleskLin` in the response headers, nginx reverse proxy is handling requests before Apache. You need to configure nginx directly (bypassing Plesk interface) to pass `/proxy/` to Apache, or route it directly to the proxy server.
**If nginx is in front of Apache (bypassing Plesk interface):**
Since nginx is handling requests before Apache, configure nginx directly by editing nginx config files.
**Option A: Configure nginx to pass `/proxy/` through to Apache:**
1. Find nginx config for your domain:
```bash
# Plesk usually stores configs here:
/etc/nginx/conf.d/vhost.conf
# or
/etc/nginx/conf.d/jumble.imwald.eu.conf
# or check Plesk's nginx vhosts:
/etc/nginx/plesk.conf.d/vhosts/jumble.imwald.eu.conf
```
2. Edit the nginx config file for `jumble.imwald.eu`
3. Add this location block BEFORE any catch-all location:
```nginx
location /proxy/ {
# Forward to Apache (check what port Apache is listening on)
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
```
**Note:** Replace `8080` with the port Apache is actually listening on. Check with:
```bash
sudo netstat -tlnp | grep apache
# or
sudo ss -tlnp | grep apache
```
4. Test nginx config: `sudo nginx -t`
5. Reload nginx: `sudo systemctl reload nginx`
**Then Apache will handle it with your existing Apache config.**
**Option B: Configure nginx to route `/proxy/` directly to the proxy server (simpler):**
1. Edit nginx config for `jumble.imwald.eu` (same location as above)
2. Add this location block BEFORE any catch-all location:
```nginx
location /proxy/ {
proxy_pass http://127.0.0.1:8090/;
proxy_set_header Host 127.0.0.1:8090;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# Don't send X-Forwarded-Host which might confuse the proxy
proxy_set_header X-Forwarded-Host "";
}
```
3. Test nginx config: `sudo nginx -t`
4. Reload nginx: `sudo systemctl reload nginx`
This bypasses Apache entirely for `/proxy/` requests and goes directly to the proxy server.
**Other possible issues:**
- The proxy server might be using the `X-Forwarded-Host` header instead of the URL path
- The proxy server might need a specific Host header value
- The proxy server might not be correctly parsing `/sites/...` path
**5. Unset forwarded headers that might confuse the proxy server:**
```apache
# The proxy server might be using X-Forwarded-Host instead of the URL path
# Unset or modify these headers for the /proxy/ path:
ProxyPass /proxy/ http://127.0.0.1:8090/
ProxyPassReverse /proxy/ http://127.0.0.1:8090/
ProxyPreserveHost Off
# Unset forwarded headers that might interfere
RequestHeader unset X-Forwarded-Host
RequestHeader unset X-Forwarded-Server
RequestHeader set Host "127.0.0.1:8090"
```
### Other Console Errors
If you see errors in the console:
- `[WebService] No proxy server configured` - `VITE_PROXY_SERVER` is undefined or empty
- `[WebService] CORS/Network error` - The proxy URL might be wrong, or CORS isn't configured