rabbitmq通过nginx代理时所需的配置

前几日安装了rabbitmq,使用正常,但是通过web界面进行管理的时候发现问题,点击具体内容的时候提示下图错误

 

 

经过排查,发现nginx 代理不全导致,配置如下即可解决问题

 

 

upstream rabbitbackend {
    server 127.0.0.1:15672;
}


server {
    listen  80;
    server_name rabbit.erps.sunnyb2b.com;
    fastcgi_connect_timeout 600;
    fastcgi_send_timeout 600;
    fastcgi_read_timeout 600;

    location / {
        port_in_redirect on;
        proxy_redirect off;
        proxy_pass http://rabbitbackend;
        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 ~* /rabbitmq/api/ {
        rewrite ^ $request_uri;
        rewrite ^/rabbitmq/api/(.*) /api/$1 break;
        return 400;
        proxy_pass http://rabbitbackend$uri;
        proxy_buffering                    off;
        proxy_set_header Host              $http_host;
        proxy_set_header X-Real-IP         $remote_addr;
        proxy_set_header X-Forwarded-For   $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }

}

 

posted @ 2021-02-19 14:08  李寅初  阅读(3267)  评论(0编辑  收藏  举报