Bỏ qua

Signoz 405 Error Fix

Problem

When trying to register on Signoz UI (http://localhost:3301/signup), you get a 405 Method Not Allowed error from Nginx.

Error Details:

  • Request: POST http://localhost:3301/api/v1/register
  • Status: 405 Not Allowed
  • Server: nginx/1.26.3

Root Cause

The Signoz frontend Docker image has its own Nginx server that serves the React app, but it's not configured to proxy /api/* requests to the query-service. When the frontend makes API calls to /api/v1/register, Nginx tries to serve it as a static file, which fails with 405.

Solution

Added a separate Nginx reverse proxy container that:

  1. Proxies /api/* requests to signoz-query-service:8080
  2. Proxies all other requests to signoz-frontend:3301
  3. Handles CORS and OPTIONS preflight requests

Changes Made

1. Added Infrastructure Nginx Reverse Proxy Container

In docker-compose.dev.yml:

infrastructure-nginx-proxy:
  image: nginx:alpine
  depends_on:
    - signoz-frontend
    - signoz-query-service
  ports:
    - '${SIGNOZ_FRONTEND_PORT:-3301}:3301'
  volumes:
    - ./config/nginx/infrastructure.conf:/etc/nginx/conf.d/default.conf:ro
  networks:
    - football-booking-network

Note: The nginx config is now in config/nginx/infrastructure.conf (not config/signoz/) for better scalability. See docs/REVERSE-PROXY-ARCHITECTURE.md for details.

2. Updated Frontend Container

Changed frontend to expose port internally only (not directly to host):

signoz-frontend:
  expose:
    - '3301' # Internal only, accessed via nginx-proxy

3. Created Nginx Configuration

Created config/signoz/nginx.conf that:

  • Proxies /api/*signoz-query-service:8080
  • Proxies /signoz-frontend:3301
  • Handles CORS and OPTIONS requests

How to Apply

Step 1: Restart Services

# Stop existing containers
docker compose -f docker-compose.dev.yml stop signoz-frontend signoz-query-service

# Start with new configuration
docker compose -f docker-compose.dev.yml up -d signoz-nginx-proxy signoz-frontend signoz-query-service

Step 2: Verify Nginx Proxy

# Check if nginx-proxy is running
docker ps | grep signoz-nginx-proxy

# Check nginx logs
docker logs signoz-nginx-proxy

# Test API endpoint through proxy
curl -X POST 'http://localhost:3301/api/v1/register' \
  -H 'Content-Type: application/json' \
  -d '{"email":"test@example.com","name":"Test","orgName":"Test Org","password":"Test123**","isAnonymous":false,"hasOptedUpdates":true}'

Step 3: Test Registration

  1. Go to http://localhost:3301/signup
  2. Fill in the registration form
  3. Click "Get Started"
  4. Should now work without 405 error

Architecture

Browser
  │
  │ http://localhost:3301/api/v1/register
  ▼
┌─────────────────────┐
│ signoz-nginx-proxy  │ (Port 3301)
│ (Nginx Reverse      │
│  Proxy)             │
└──────────┬──────────┘
           │
    ┌──────┴──────┐
    │             │
    ▼             ▼
┌──────────┐  ┌──────────────────┐
│ Frontend │  │ Query Service    │
│ :3301    │  │ :8080            │
└──────────┘  └──────────────────┘

Troubleshooting

Still Getting 405?

  1. Check if nginx-proxy is running:

bash docker ps | grep infrastructure-nginx-proxy

  1. Check nginx configuration:

bash docker exec infrastructure-nginx-proxy nginx -t

  1. Check nginx logs:

bash docker logs infrastructure-nginx-proxy

  1. Verify query-service is accessible:

bash curl http://localhost:8083/api/health

  1. Test direct API call: bash curl -X POST 'http://localhost:8083/api/v1/register' \ -H 'Content-Type: application/json' \ -d '{"email":"test@example.com","name":"Test","orgName":"Test","password":"Test123**","isAnonymous":false}'

CORS Errors?

The Nginx config includes CORS headers. If you still see CORS errors:

  1. Check browser console for specific error
  2. Verify Access-Control-Allow-Origin header is present
  3. Check if OPTIONS preflight is being handled

Frontend Not Loading?

  1. Check frontend container:

bash docker logs signoz-frontend

  1. Verify frontend is accessible internally:

bash docker exec signoz-nginx-proxy wget -O- http://signoz-frontend:3301

  1. Check network connectivity: bash docker network inspect football-booking-network | grep signoz

Alternative Solutions

If the Nginx proxy approach doesn't work, you can:

  1. Access query-service directly (but will have CORS issues):
  2. Change frontend to call http://localhost:8083/api/v1/register directly
  3. Requires modifying Signoz frontend code (not recommended)

  4. Use Signoz unified service (newer versions):

  5. Some newer Signoz versions have a unified frontend+API service
  6. Check Signoz documentation for latest setup

  7. Custom frontend build:

  8. Rebuild Signoz frontend with custom API endpoint configuration
  9. More complex but gives full control

Notes

  • The Nginx proxy adds a small latency overhead (~1-2ms)
  • All API requests now go through the proxy
  • Static assets are still served efficiently
  • CORS is handled at the proxy level

Verification

After applying the fix, you should be able to:

  • ✅ Access Signoz UI at http://localhost:3301
  • ✅ Register a new account without 405 errors
  • ✅ Make API calls through the proxy
  • ✅ See traces, metrics, and logs in Signoz