Skip to content

Commit 6140276

Browse files
author
Paul C
committed
Fix: $scheme variable now correctly uses HTTPS connection status
- Added is_https parameter to handle_proxy function - Added is_https parameter to expand_proxy_header_value function - $scheme now correctly returns 'https' when client connects via SSL - Fixes WordPress login cookie issues when behind reverse proxy
1 parent f72fdb4 commit 6140276

5 files changed

Lines changed: 273 additions & 57 deletions

File tree

.codewolf/conversation_codewolf.json

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,8 +449,68 @@
449449
"role": "system",
450450
"content": "\n╔═══════════════════════════════════════╗\n║ 🐺 CODEWOLF DIAGNOSTICS ║\n╚═══════════════════════════════════════╝\n\n📁 WORKSPACE\n 1. wolfproxy (/home/paulc/NetBeansProjects/wolfproxy)\n\n💾 DATABASE CONFIG\n Host: 127.0.0.1\n Database: firestorm\n Username: lone\n Project: codewolf\n\n🔄 TRANSLATION/REWRITING MODE\n From: c\n To: web application with php, html and javascript\n Source dir: /home/paulc/NetBeansProjects/firestorm/viewercode/\n Dest dir: /home/paulc/NetBeansProjects/firestorm/wolfstorm/\n ⚠️ Will examine source files first\n Context: This is a rewrite of the Firestorm OpenSim/Second Life viewer from c# to a beaut...\n\n🤖 AI MODELS CONFIG\n AI-1: local/gemini-2.5-flash\n AI-2: local/gemini-2.5-flash\n\n🔍 CONNECTIVITY TESTS\n ⚠️ AI-1: Error: Ollama/Local AI request failed: Ollama request failed: Not Found\n\nPossible causes:\n• Ollama server not running (start with: ollama serve)\n• Incorrect host URL in settings\n• Model not pulled (run: ollama pull <model>)\n• Network connectivity issues\n• Port conflict or firewall blocking\n\nCheck settings: AI-1/AI-2 Provider and Local AI Host\n ⚠️ AI-2: Error: Ollama/Local AI request failed: Ollama request failed: Not Found\n\nPossible causes:\n• Ollama server not running (start with: ollama serve)\n• Incorrect host URL in settings\n• Model not pulled (run: ollama pull <model>)\n• Network connectivity issues\n• Port conflict or firewall blocking\n\nCheck settings: AI-1/AI-2 Provider and Local AI Host\n\n💾 DATABASE STRUCTURE & CONTENTS\n ✅ Connection: Successful\n 📋 Database Tables (All Projects):\n • code_entities: 17186 total records\n • code_relationships: 9085 total records\n • indexed_files: 1739 files\n\n 📂 SOURCE PROJECT: \"codewolf\"\n • Entities indexed: 10038\n • Relationships: 9085\n • Files indexed: 1739\n\n 📑 Source Entity Types:\n • class: 6788\n • function: 3250\n\n 🔤 Source Languages:\n • c: 8190 entities\n • cpp: 1441 entities\n • python: 338 entities\n • r: 64 entities\n • shell: 5 entities\n\n ✅ Source code indexed with 10038 entities!\n\n 🎯 DESTINATION PROJECT: \"codewolf-dest\"\n • Entities indexed: 119\n • Relationships: 0\n • Files indexed: 98\n\n 📑 Destination Entity Types:\n • class: 103\n • function: 16\n\n 🔤 Destination Languages:\n • javascript: 104 entities\n • php: 8 entities\n • python: 7 entities\n\n ✅ Destination code indexed with 119 entities!\n\n⚠️ Some systems need attention\n\nTroubleshooting:\n• Check API keys: Ctrl+, → Search \"AI Code Assistant\"\n• Verify database: sudo systemctl status mariadb\n• Run indexer: python3 code_indexer.py\n• Check logs: View > Output > CodeWolf\n• Restart diagnostics: Ctrl+Shift+P → \"Run System Diagnostics\"\n\n",
451451
"timestamp": "2026-01-18T18:11:25.770Z"
452+
},
453+
{
454+
"role": "system",
455+
"content": "🔍 Testing AI-1 (Architect)...",
456+
"timestamp": "2026-01-19T05:31:59.233Z"
457+
},
458+
{
459+
"role": "system",
460+
"content": "🔍 Testing AI-2 (Implementer)...",
461+
"timestamp": "2026-01-19T05:31:59.240Z"
462+
},
463+
{
464+
"role": "system",
465+
"content": "🔍 Testing database connection and scanning indexed code...",
466+
"timestamp": "2026-01-19T05:31:59.244Z"
467+
},
468+
{
469+
"role": "system",
470+
"content": "\n╔═══════════════════════════════════════╗\n║ 🐺 CODEWOLF DIAGNOSTICS ║\n╚═══════════════════════════════════════╝\n\n📁 WORKSPACE\n 1. wolfproxy (/home/paulc/NetBeansProjects/wolfproxy)\n\n💾 DATABASE CONFIG\n Host: 127.0.0.1\n Database: firestorm\n Username: lone\n Project: codewolf\n\n🔄 TRANSLATION/REWRITING MODE\n From: c\n To: web application with php, html and javascript\n Source dir: /home/paulc/NetBeansProjects/firestorm/viewercode/\n Dest dir: /home/paulc/NetBeansProjects/firestorm/wolfstorm/\n ⚠️ Will examine source files first\n Context: This is a rewrite of the Firestorm OpenSim/Second Life viewer from c# to a beaut...\n\n🤖 AI MODELS CONFIG\n AI-1: local/gemini-2.5-flash\n AI-2: local/gemini-2.5-flash\n\n🔍 CONNECTIVITY TESTS\n ⚠️ AI-1: Error: Ollama/Local AI request failed: Ollama request failed: Not Found\n\nPossible causes:\n• Ollama server not running (start with: ollama serve)\n• Incorrect host URL in settings\n• Model not pulled (run: ollama pull <model>)\n• Network connectivity issues\n• Port conflict or firewall blocking\n\nCheck settings: AI-1/AI-2 Provider and Local AI Host\n ⚠️ AI-2: Error: Ollama/Local AI request failed: Ollama request failed: Not Found\n\nPossible causes:\n• Ollama server not running (start with: ollama serve)\n• Incorrect host URL in settings\n• Model not pulled (run: ollama pull <model>)\n• Network connectivity issues\n• Port conflict or firewall blocking\n\nCheck settings: AI-1/AI-2 Provider and Local AI Host\n\n💾 DATABASE STRUCTURE & CONTENTS\n ✅ Connection: Successful\n 📋 Database Tables (All Projects):\n • code_entities: 17186 total records\n • code_relationships: 9085 total records\n • indexed_files: 1739 files\n\n 📂 SOURCE PROJECT: \"codewolf\"\n • Entities indexed: 10038\n • Relationships: 9085\n • Files indexed: 1739\n\n 📑 Source Entity Types:\n • class: 6788\n • function: 3250\n\n 🔤 Source Languages:\n • c: 8190 entities\n • cpp: 1441 entities\n • python: 338 entities\n • r: 64 entities\n • shell: 5 entities\n\n ✅ Source code indexed with 10038 entities!\n\n 🎯 DESTINATION PROJECT: \"codewolf-dest\"\n • Entities indexed: 119\n • Relationships: 0\n • Files indexed: 98\n\n 📑 Destination Entity Types:\n • class: 103\n • function: 16\n\n 🔤 Destination Languages:\n • javascript: 104 entities\n • php: 8 entities\n • python: 7 entities\n\n ✅ Destination code indexed with 119 entities!\n\n⚠️ Some systems need attention\n\nTroubleshooting:\n• Check API keys: Ctrl+, → Search \"AI Code Assistant\"\n• Verify database: sudo systemctl status mariadb\n• Run indexer: python3 code_indexer.py\n• Check logs: View > Output > CodeWolf\n• Restart diagnostics: Ctrl+Shift+P → \"Run System Diagnostics\"\n\n",
471+
"timestamp": "2026-01-19T05:31:59.281Z"
472+
},
473+
{
474+
"role": "system",
475+
"content": "🔍 Testing AI-1 (Architect)...",
476+
"timestamp": "2026-01-19T05:35:31.807Z"
477+
},
478+
{
479+
"role": "system",
480+
"content": "🔍 Testing AI-2 (Implementer)...",
481+
"timestamp": "2026-01-19T05:35:31.814Z"
482+
},
483+
{
484+
"role": "system",
485+
"content": "🔍 Testing database connection and scanning indexed code...",
486+
"timestamp": "2026-01-19T05:35:31.816Z"
487+
},
488+
{
489+
"role": "system",
490+
"content": "\n╔═══════════════════════════════════════╗\n║ 🐺 CODEWOLF DIAGNOSTICS ║\n╚═══════════════════════════════════════╝\n\n📁 WORKSPACE\n 1. wolfproxy (/home/paulc/NetBeansProjects/wolfproxy)\n\n💾 DATABASE CONFIG\n Host: 127.0.0.1\n Database: firestorm\n Username: lone\n Project: codewolf\n\n🔄 TRANSLATION/REWRITING MODE\n From: c\n To: web application with php, html and javascript\n Source dir: /home/paulc/NetBeansProjects/firestorm/viewercode/\n Dest dir: /home/paulc/NetBeansProjects/firestorm/wolfstorm/\n ⚠️ Will examine source files first\n Context: This is a rewrite of the Firestorm OpenSim/Second Life viewer from c# to a beaut...\n\n🤖 AI MODELS CONFIG\n AI-1: local/gemini-2.5-flash\n AI-2: local/gemini-2.5-flash\n\n🔍 CONNECTIVITY TESTS\n ⚠️ AI-1: Error: Ollama/Local AI request failed: Ollama request failed: Not Found\n\nPossible causes:\n• Ollama server not running (start with: ollama serve)\n• Incorrect host URL in settings\n• Model not pulled (run: ollama pull <model>)\n• Network connectivity issues\n• Port conflict or firewall blocking\n\nCheck settings: AI-1/AI-2 Provider and Local AI Host\n ⚠️ AI-2: Error: Ollama/Local AI request failed: Ollama request failed: Not Found\n\nPossible causes:\n• Ollama server not running (start with: ollama serve)\n• Incorrect host URL in settings\n• Model not pulled (run: ollama pull <model>)\n• Network connectivity issues\n• Port conflict or firewall blocking\n\nCheck settings: AI-1/AI-2 Provider and Local AI Host\n\n💾 DATABASE STRUCTURE & CONTENTS\n ✅ Connection: Successful\n 📋 Database Tables (All Projects):\n • code_entities: 17186 total records\n • code_relationships: 9085 total records\n • indexed_files: 1739 files\n\n 📂 SOURCE PROJECT: \"codewolf\"\n • Entities indexed: 10038\n • Relationships: 9085\n • Files indexed: 1739\n\n 📑 Source Entity Types:\n • class: 6788\n • function: 3250\n\n 🔤 Source Languages:\n • c: 8190 entities\n • cpp: 1441 entities\n • python: 338 entities\n • r: 64 entities\n • shell: 5 entities\n\n ✅ Source code indexed with 10038 entities!\n\n 🎯 DESTINATION PROJECT: \"codewolf-dest\"\n • Entities indexed: 119\n • Relationships: 0\n • Files indexed: 98\n\n 📑 Destination Entity Types:\n • class: 103\n • function: 16\n\n 🔤 Destination Languages:\n • javascript: 104 entities\n • php: 8 entities\n • python: 7 entities\n\n ✅ Destination code indexed with 119 entities!\n\n⚠️ Some systems need attention\n\nTroubleshooting:\n• Check API keys: Ctrl+, → Search \"AI Code Assistant\"\n• Verify database: sudo systemctl status mariadb\n• Run indexer: python3 code_indexer.py\n• Check logs: View > Output > CodeWolf\n• Restart diagnostics: Ctrl+Shift+P → \"Run System Diagnostics\"\n\n",
491+
"timestamp": "2026-01-19T05:35:31.837Z"
492+
},
493+
{
494+
"role": "system",
495+
"content": "🔍 Testing AI-1 (Architect)...",
496+
"timestamp": "2026-01-19T05:36:09.509Z"
497+
},
498+
{
499+
"role": "system",
500+
"content": "🔍 Testing AI-2 (Implementer)...",
501+
"timestamp": "2026-01-19T05:36:09.515Z"
502+
},
503+
{
504+
"role": "system",
505+
"content": "🔍 Testing database connection and scanning indexed code...",
506+
"timestamp": "2026-01-19T05:36:09.517Z"
507+
},
508+
{
509+
"role": "system",
510+
"content": "\n╔═══════════════════════════════════════╗\n║ 🐺 CODEWOLF DIAGNOSTICS ║\n╚═══════════════════════════════════════╝\n\n📁 WORKSPACE\n 1. wolfproxy (/home/paulc/NetBeansProjects/wolfproxy)\n\n💾 DATABASE CONFIG\n Host: 127.0.0.1\n Database: firestorm\n Username: lone\n Project: codewolf\n\n🔄 TRANSLATION/REWRITING MODE\n From: c\n To: web application with php, html and javascript\n Source dir: /home/paulc/NetBeansProjects/firestorm/viewercode/\n Dest dir: /home/paulc/NetBeansProjects/firestorm/wolfstorm/\n ⚠️ Will examine source files first\n Context: This is a rewrite of the Firestorm OpenSim/Second Life viewer from c# to a beaut...\n\n🤖 AI MODELS CONFIG\n AI-1: local/gemini-2.5-flash\n AI-2: local/gemini-2.5-flash\n\n🔍 CONNECTIVITY TESTS\n ⚠️ AI-1: Error: Ollama/Local AI request failed: Ollama request failed: Not Found\n\nPossible causes:\n• Ollama server not running (start with: ollama serve)\n• Incorrect host URL in settings\n• Model not pulled (run: ollama pull <model>)\n• Network connectivity issues\n• Port conflict or firewall blocking\n\nCheck settings: AI-1/AI-2 Provider and Local AI Host\n ⚠️ AI-2: Error: Ollama/Local AI request failed: Ollama request failed: Not Found\n\nPossible causes:\n• Ollama server not running (start with: ollama serve)\n• Incorrect host URL in settings\n• Model not pulled (run: ollama pull <model>)\n• Network connectivity issues\n• Port conflict or firewall blocking\n\nCheck settings: AI-1/AI-2 Provider and Local AI Host\n\n💾 DATABASE STRUCTURE & CONTENTS\n ✅ Connection: Successful\n 📋 Database Tables (All Projects):\n • code_entities: 17186 total records\n • code_relationships: 9085 total records\n • indexed_files: 1739 files\n\n 📂 SOURCE PROJECT: \"codewolf\"\n • Entities indexed: 10038\n • Relationships: 9085\n • Files indexed: 1739\n\n 📑 Source Entity Types:\n • class: 6788\n • function: 3250\n\n 🔤 Source Languages:\n • c: 8190 entities\n • cpp: 1441 entities\n • python: 338 entities\n • r: 64 entities\n • shell: 5 entities\n\n ✅ Source code indexed with 10038 entities!\n\n 🎯 DESTINATION PROJECT: \"codewolf-dest\"\n • Entities indexed: 119\n • Relationships: 0\n • Files indexed: 98\n\n 📑 Destination Entity Types:\n • class: 103\n • function: 16\n\n 🔤 Destination Languages:\n • javascript: 104 entities\n • php: 8 entities\n • python: 7 entities\n\n ✅ Destination code indexed with 119 entities!\n\n⚠️ Some systems need attention\n\nTroubleshooting:\n• Check API keys: Ctrl+, → Search \"AI Code Assistant\"\n• Verify database: sudo systemctl status mariadb\n• Run indexer: python3 code_indexer.py\n• Check logs: View > Output > CodeWolf\n• Restart diagnostics: Ctrl+Shift+P → \"Run System Diagnostics\"\n\n",
511+
"timestamp": "2026-01-19T05:36:09.555Z"
452512
}
453513
],
454514
"context": null,
455-
"lastUpdated": "2026-01-18T18:11:25.771Z"
515+
"lastUpdated": "2026-01-19T05:36:09.555Z"
456516
}

README.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,97 @@ The monitoring dashboard is protected with HTTP Basic Authentication. **Change t
238238
| Lua Scripting | Yes | No |
239239
| Module System | Yes | No (but extensible in Rust) |
240240

241+
## WordPress Behind WolfProxy
242+
243+
When running WordPress behind WolfProxy (or any reverse proxy), you may encounter issues such as:
244+
245+
- "Cookies are blocked or not supported by your browser" login errors
246+
- Redirect loops
247+
- Mixed content warnings
248+
- Session issues
249+
250+
### Recommended nginx Configuration for WordPress
251+
252+
For WordPress sites, use this location block configuration:
253+
254+
```nginx
255+
server {
256+
listen 443 ssl;
257+
server_name your-wordpress-site.com;
258+
259+
ssl_certificate /etc/letsencrypt/live/your-wordpress-site.com/fullchain.pem;
260+
ssl_certificate_key /etc/letsencrypt/live/your-wordpress-site.com/privkey.pem;
261+
262+
location / {
263+
proxy_set_header Host $host;
264+
proxy_set_header X-Real-IP $remote_addr;
265+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
266+
proxy_set_header X-Forwarded-Proto $scheme;
267+
268+
# Cookie handling for WordPress
269+
proxy_set_header Cookie $http_cookie;
270+
proxy_pass_header Set-Cookie;
271+
proxy_cookie_path / /;
272+
273+
# Disable buffering for better cookie handling
274+
proxy_buffering off;
275+
276+
proxy_pass http://backend_servers;
277+
}
278+
}
279+
```
280+
281+
### WordPress wp-config.php Settings
282+
283+
Add these lines to your `wp-config.php` file (before "That's all, stop editing!"):
284+
285+
```php
286+
/**
287+
* Reverse Proxy Configuration
288+
* Required when WordPress is behind a reverse proxy like WolfProxy
289+
*/
290+
291+
// Trust the proxy's X-Forwarded-Proto header for HTTPS detection
292+
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
293+
$_SERVER['HTTPS'] = 'on';
294+
}
295+
296+
// Trust X-Forwarded-For for real client IP
297+
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
298+
$forwarded_ips = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
299+
$_SERVER['REMOTE_ADDR'] = trim($forwarded_ips[0]);
300+
}
301+
302+
// Force SSL for admin (recommended)
303+
define('FORCE_SSL_ADMIN', true);
304+
305+
// Optional: Set cookie domain if you have issues with subdomains
306+
// define('COOKIE_DOMAIN', 'your-wordpress-site.com');
307+
308+
// Optional: Define site URL to prevent redirect loops
309+
// define('WP_HOME', 'https://your-wordpress-site.com');
310+
// define('WP_SITEURL', 'https://your-wordpress-site.com');
311+
```
312+
313+
### Troubleshooting WordPress Cookie Issues
314+
315+
1. **Clear your browser cookies** for the WordPress site after making configuration changes
316+
317+
2. **Check that your site URL is correct** in WordPress Settings → General (Site URL and WordPress URL should both use `https://`)
318+
319+
3. **Verify headers are being passed** by checking your server logs or using browser developer tools to inspect request/response headers
320+
321+
4. **If using load balancing with multiple backends**, ensure you're using `ip_hash` for sticky sessions:
322+
```nginx
323+
upstream backend_servers {
324+
ip_hash;
325+
server 10.0.10.101;
326+
server 10.0.10.102;
327+
}
328+
```
329+
330+
5. **Check for redirect loops** - if WordPress and your proxy disagree about HTTP vs HTTPS, you'll get infinite redirects. The `X-Forwarded-Proto` header and `wp-config.php` settings above should fix this.
331+
241332
## License
242333

243334
MIT License - See LICENSE file

0 commit comments

Comments
 (0)