📄 SKILL.md

← Vault

name: chatwoot-nginx-underscore-header-fix

description: Fix Chatwoot 401 errors caused by nginx dropping underscores_in_headers


Chatwoot + Nginx: 401 Unauthorized despite valid token

Problem

Chatwoot self-hosted behind nginx returns 401 on API calls even with a valid api_access_token. The token exists in the database and belongs to a valid user.

Root Cause

Nginx's default underscores_in_headers off silently drops headers containing underscores. The Chatwoot API uses api_access_token header — which never reaches the upstream Chatwoot Rails app.

Solution

Add to /etc/nginx/nginx.conf inside the http { } block:

`

underscores_in_headers on;

`

Then reload: nginx -s reload

Verification

`bash

From outside

curl -s "https://chat.rochasalesseguros.com.br/api/v1/accounts/1/inboxes.json" \

-H "api_access_token: TOKEN_HERE"

Inside container (if Docker)

docker exec root-rails-1 curl -s "http://localhost:3000/api/v1/accounts/1/inboxes.json" \

-H "api_access_token: TOKEN_HERE"

`

Environment