{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreid47y52vfnnrwbc34edkwxjsxmkxddxmfpz2gq46wplookaa6laqy",
"uri": "at://did:plc:25rdn5elo5izoxrmtis34zuk/app.bsky.feed.post/3mplaxjomxaj2"
},
"coverImage": {
"$type": "blob",
"ref": {
"$link": "bafkreidn33j3p5z5wx2covyr23xsrqn75qewp4xjnzq5gkmylekdrpi6fy"
},
"mimeType": "image/webp",
"size": 70672
},
"path": "/aswindanu_anwar_38c31d278/proxying-rabbitmq-management-ui-through-nginx-fixing-the-2f-problem-3dj0",
"publishedAt": "2026-07-01T09:40:01.000Z",
"site": "https://dev.to",
"tags": [
"nginx",
"devops",
"tutorial",
"rabbitmq"
],
"textContent": "## The Problem\n\nWhen you put RabbitMQ's Management UI behind an nginx reverse proxy under a\nsub-path like `/rabbitmq/`, queue detail pages and many API calls break silently.\n\nThe root cause: nginx normalizes the request URI before proxying. It decodes\n`%2F` (the URL-encoded forward slash) into a literal `/`. RabbitMQ's Management\nAPI uses `%2F` to represent the **default virtual host** (`/`) in API paths:\n\n\n GET /api/queues/%2F/my-queue\n\n\nWhen nginx decodes it:\n\n\n GET /api/queues///my-queue ← broken\n\n\n## What Doesn't Work\n\nThe common advice of using `merge_slashes off` or a `rewrite` directive doesn't\nfully solve this because nginx still normalizes `$uri` before forwarding.\n\n## The Fix\n\nUse `$request_uri` inside an `if` block. Unlike `$uri`, `$request_uri` holds\nthe **raw, undecoded URI exactly as the client sent it** — nginx never touches it.\n\n\n nginx\n # RabbitMQ: API paths — use $request_uri to preserve %2F (never decoded by nginx)\n location ~* ^/rabbitmq/api/ {\n if ($request_uri ~* \"^/rabbitmq/(.*)\") {\n proxy_pass http://rabbitmq:15672/$1;\n }\n proxy_buffering off;\n proxy_set_header Host $host;\n proxy_set_header X-Real-IP $remote_addr;\n proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n proxy_set_header X-Forwarded-Proto https;\n }\n\n # RabbitMQ: general UI (JS, CSS, static assets, non-API pages)\n location ~* ^/rabbitmq/ {\n rewrite ^/rabbitmq/(.*)$ /$1 break;\n proxy_pass http://rabbitmq:15672;\n proxy_buffering off;\n proxy_set_header Host $host;\n proxy_set_header X-Real-IP $remote_addr;\n proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n proxy_set_header X-Forwarded-Proto https;\n }\n",
"title": "Proxying RabbitMQ Management UI Through Nginx (Fixing the %2F Problem)"
}