使用Nginx反向代理RabbitMQ管理界面
当访问Channels、Exchanges、Queues等详情时,出现以下错误信息
Not found
The object you clicked on was not found; it may have been deleted on the server.
原因
访问Queues这些详情信息时,请求以/api
开头的URL,其中带有%2F
这类的特殊符号,因此需要单独反向代理/api/
路径,并重写请求uri。
参考配置
其中,
/rmq/
是我这边根据场景需求设置的路径前缀,大家可以将配置中所有的/rmq/
替换成自己想要设置的前缀,也可以直接是/
。
server{
listen 9000;
server_name localhost;
location /rmq/ {
port_in_redirect on;
proxy_redirect off;
proxy_pass http://localhost:15672/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header User-Agent $http_user_agent;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /rmq/api/ {
rewrite ^ $request_uri;
rewrite ^/rmq/api/(.*) /api/$1 break;
port_in_redirect on;
proxy_redirect off;
proxy_pass http://localhost:15672/api/$1;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header User-Agent $http_user_agent;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}