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.
Angelcore is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.