mirror of
https://github.com/thecyberlearn/quantumtaskai-caprover.git
synced 2026-08-18 08:52:57 +00:00
Add comprehensive Django debug logging for 404 troubleshooting
- Container and port 3000 are working (simple HTTP server test passed) - Issue is Django-specific routing, not Dokploy - Added debug middleware to log all incoming requests - Added debug_settings.py with enhanced logging and URL pattern display - Updated Dockerfile.dokploy.debug to use debug settings - Added proper ALLOWED_HOSTS with full domain - This will show us exactly which requests Django receives and how it responds
This commit is contained in:
parent
b9b5375537
commit
01d3854194
@ -23,7 +23,7 @@ ENV PYTHONUNBUFFERED=1 \
|
||||
ALLOWED_HOSTS="*"
|
||||
|
||||
# Collect static files
|
||||
RUN python manage.py collectstatic --noinput --settings=netcop_hub.settings || true
|
||||
RUN python manage.py collectstatic --noinput --settings=debug_settings || true
|
||||
|
||||
# Make startup script executable
|
||||
RUN chmod +x start-dokploy.sh
|
||||
@ -33,7 +33,7 @@ EXPOSE 3000
|
||||
|
||||
# Debug: Print Django info
|
||||
RUN python manage.py --version
|
||||
RUN python manage.py check --settings=netcop_hub.settings || true
|
||||
RUN python manage.py check --settings=debug_settings || true
|
||||
|
||||
# Start with debug info
|
||||
CMD echo "🐛 Debug Mode - Django $(python manage.py --version)" && \
|
||||
@ -42,13 +42,16 @@ CMD echo "🐛 Debug Mode - Django $(python manage.py --version)" && \
|
||||
echo " - ALLOWED_HOSTS: $ALLOWED_HOSTS" && \
|
||||
echo " - SECRET_KEY: $(echo $SECRET_KEY | cut -c1-10)..." && \
|
||||
echo "🌐 Testing Django config..." && \
|
||||
python manage.py check --settings=netcop_hub.settings && \
|
||||
python manage.py check --settings=debug_settings && \
|
||||
echo "✅ Django config OK" && \
|
||||
echo "🚀 Starting server..." && \
|
||||
gunicorn netcop_hub.wsgi:application \
|
||||
echo "🧪 Testing URL patterns..." && \
|
||||
python manage.py show_urls --settings=debug_settings || echo "show_urls not available" && \
|
||||
echo "🚀 Starting server with detailed logging..." && \
|
||||
DJANGO_SETTINGS_MODULE=debug_settings gunicorn netcop_hub.wsgi:application
|
||||
--bind 0.0.0.0:3000 \
|
||||
--workers 1 \
|
||||
--timeout 120 \
|
||||
--log-level debug \
|
||||
--access-logfile - \
|
||||
--error-logfile -
|
||||
--error-logfile - \
|
||||
--capture-output
|
||||
|
||||
33
debug_middleware.py
Normal file
33
debug_middleware.py
Normal file
@ -0,0 +1,33 @@
|
||||
"""
|
||||
Debug middleware for troubleshooting Dokploy 404 issues
|
||||
"""
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class DebugRequestMiddleware:
|
||||
"""Middleware to log all incoming requests for debugging"""
|
||||
|
||||
def __init__(self, get_response):
|
||||
self.get_response = get_response
|
||||
|
||||
def __call__(self, request):
|
||||
# Log incoming request details
|
||||
logger.info(f"🌐 INCOMING REQUEST:")
|
||||
logger.info(f" - Method: {request.method}")
|
||||
logger.info(f" - Path: {request.path}")
|
||||
logger.info(f" - Full Path: {request.get_full_path()}")
|
||||
logger.info(f" - Host: {request.get_host()}")
|
||||
logger.info(f" - User Agent: {request.META.get('HTTP_USER_AGENT', 'Unknown')[:100]}")
|
||||
logger.info(f" - Remote IP: {request.META.get('REMOTE_ADDR', 'Unknown')}")
|
||||
logger.info(f" - Headers: {dict(request.headers)}")
|
||||
|
||||
# Process request
|
||||
response = self.get_response(request)
|
||||
|
||||
# Log response
|
||||
logger.info(f"📤 RESPONSE:")
|
||||
logger.info(f" - Status Code: {response.status_code}")
|
||||
logger.info(f" - Content Type: {response.get('Content-Type', 'Unknown')}")
|
||||
|
||||
return response
|
||||
32
debug_settings.py
Normal file
32
debug_settings.py
Normal file
@ -0,0 +1,32 @@
|
||||
# Debug settings for Dokploy troubleshooting
|
||||
from netcop_hub.settings import *
|
||||
|
||||
# Enable debug mode
|
||||
DEBUG = True
|
||||
|
||||
# Add debug middleware at the top
|
||||
MIDDLEWARE = ['debug_middleware.DebugRequestMiddleware'] + MIDDLEWARE
|
||||
|
||||
# Enhanced logging
|
||||
LOGGING['loggers']['root']['level'] = 'DEBUG'
|
||||
LOGGING['handlers']['console']['level'] = 'DEBUG'
|
||||
|
||||
# Print all URLs at startup
|
||||
print("🔗 Available URL patterns:")
|
||||
try:
|
||||
from django.urls import get_resolver
|
||||
resolver = get_resolver()
|
||||
url_patterns = []
|
||||
|
||||
def extract_patterns(patterns, prefix=''):
|
||||
for pattern in patterns:
|
||||
if hasattr(pattern, 'url_patterns'):
|
||||
extract_patterns(pattern.url_patterns, prefix + str(pattern.pattern))
|
||||
else:
|
||||
url_patterns.append(prefix + str(pattern.pattern))
|
||||
|
||||
extract_patterns(resolver.url_patterns)
|
||||
for pattern in url_patterns[:20]: # Show first 20
|
||||
print(f" - {pattern}")
|
||||
except Exception as e:
|
||||
print(f" - Error loading URL patterns: {e}")
|
||||
@ -10,6 +10,7 @@
|
||||
"PYTHONUNBUFFERED": "1",
|
||||
"DEBUG": "true",
|
||||
"SECRET_KEY": "debug-key-change-in-production-123456789",
|
||||
"ALLOWED_HOSTS": "*"
|
||||
"ALLOWED_HOSTS": "website-quantumtaskai-wrczik-cc50ac-31-97-62-205.traefik.me,localhost,127.0.0.1,*",
|
||||
"DOKPLOY_PROJECT_NAME": "quantum-tasks-ai"
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user