Issue with RabbitMQ management API

So I’ve been stuck for quite a while and would appreciate any help to try and find a solution.

I have a docker environment with nginx, rabbitmq and some other containers. The idea is to use the nginx as a proxy. So far so good, but when trying to open specific Exchanges or Queues I’m getting error 404 not found. I’ve checked documentation and tried multiple provided solutions but can’t get it to work. The docker compose file exposes only the 5672 port for listening, the management port is not exposed (due to security reasons) and the connection is via the internal docker network. Current nginx config file:

http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
    access_log  /var/log/nginx/access.log  main;
    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   70;
    types_hash_max_size 2048;
    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;
    ssl_certificate /etc/ssl/test.crt; #hidden for the post purposes
    ssl_certificate_key /etc/ssl/test.key; #hidden for the post purposes
    ssl_protocols   TLSv1.3 TLSv1.2;
    ssl_ciphers  #hidden for the post purposes;
    ssl_prefer_server_ciphers   on;
    ssl_session_cache   shared:SSL:10m;
    ssl_session_timeout 10m;

    server {
        listen 80 default_server;
        location / {
           return 301 https://example.com:443$request_uri;
        }
    }
    server {
        listen 443 ssl http2 ;
        server_name  1.1.1.1;
        return 301 https://example.com:443$request_uri;
    }

    server {
        listen 443 ssl http2 ;
        #listen [::]:443 ssl http2 default_server;
        server_name example.com;
        gzip on;
        gzip_types application/javascript image/* text/css application/json;
        gzip_proxied    no-cache no-store private expired auth;
        gzip_min_length 1000;
        gunzip on;
    location /api {
                    proxy_pass http://anotherapp:3000;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'upgrade';
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_cache_bypass $http_upgrade;
        }
        
    location /auth {
                        proxy_pass http://anotherapp:3000;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'upgrade';
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_cache_bypass $http_upgrade;
        }
        location /rabbitmq/api/(.?)/(.){
            proxy_pass http://rabbitmq:15672/api/$1/%2F/$2?$query_string;
            proxy_buffering                    off;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'upgrade';
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_cache_bypass $http_upgrade;
        }
        location /rabbitmq/{
            rewrite ^/rabbitmq/(.*)$ /$1 break;
            proxy_pass http://rabbitmq:15672/;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'upgrade';
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_cache_bypass $http_upgrade;
        }
    }   
}

Current docker-compose.yml file:

version: '3'
services:
  nginx:
    image: nginx:1.26.0
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - /etc/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
    restart: always
    networks:
      internal:
        aliases:
          - nginx
  anotherapp
    restart: always 
    networks:
      internal:
        aliases:
          - anotherapp
  rabbitmq:
    image: rabbitmq:3.13-management
    hostname: "my-rabbit"
    environment:
      RABBITMQ_DEFAULT_USER: example
      RABBITMQ_DEFAULT_PASS: example
    volumes:
      - /etc/rabbitmq:/etc/rabbitmq
      - /var/log/rabbitmq:/var/log/rabbitmq
    healthcheck:
      test: rabbitmq-diagnostics -q ping
      interval: 30s
      timeout: 10s
      retries: 5
    restart: always
    ports:
      - "5672:5672"
    networks:
      internal:
        aliases:
          - rabbitmq
networks:
  internal:
    driver: bridge

Example request being sent when trying to open a certain exchange or a queue via the Web interface:
https://example.com/rabbitmq/api/exchanges/%2F/test?msg_rates_age=60&msg_rates_incr=5
Request Method:
GET
Status Code:
404 Not Found
Remote Address:
IP:443

The same is when trying to create a new exchange/queue but there is error 405 Method Not Allowed (it’s trying PUT method, most likely not specifically related to the issue above)

I’ve tried multiple rewrite options and also changing the location patterns and so on but nothing worked.

New contributor

Angelcore is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật