Django:如何在生产模式下访问 celery 花页面?

标签 django nginx celery flower

在开发模式(本地)下,真的很容易访问花页( http://localhost:5555 )

但是在生产模式下,很难访问花页。

我想使用以下网址访问花卉仪表板页面:
https://spacegraphy.choislaw.xyz/flower/ (域名:choislaw.xyz)

我引用了http://flower.readthedocs.io/en/latest/reverse-proxy.html#reverse-proxy这就是我所做的:

nginx.conf

  http {
      include       mime.types;
      default_type  application/octet-stream;
      sendfile        on;

      server {
          listen       80;
          server_name  spacegraphy.choislaw.xyz;

          client_max_body_size 4G;
          keepalive_timeout 5;

          return 301 https://$server_name$request_uri;
      }


      # HTTPS server
      server {
          listen       443 default_server ssl;
          server_name  spacegraphy.choislaw.xyz;

          client_max_body_size 4G;
          keepalive_timeout 5;

          ssl_certificate      /etc/letsencrypt/live/spacegraphy.choislaw.xyz/fullchain.pem;
          ssl_certificate_key  /etc/letsencrypt/live/spacegraphy.choislaw.xyz/privkey.pem;

          location / {
              proxy_pass_header X-CSRFToken;
              proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
              proxy_set_header X-Forwarded-Proto https;
              proxy_set_header X-Real-IP $remote_addr;
              proxy_set_header HOST $http_host;
              proxy_set_header X-NginX-Proxy true;

              proxy_pass http://127.0.0.1:4349;
              proxy_redirect off;
          }

          # Flower
          location /flower/ {
              proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
              proxy_set_header X-Forwarded-Proto https;
              proxy_set_header X-Real-IP $remote_addr;
              proxy_set_header HOST $http_host;
              proxy_set_header Upgrade $http_upgrade;
              proxy_set_header Connection "upgrade";
              proxy_http_version 1.1;

             proxy_pass http://localhost:5555/;
             proxy_redirect off;
         }
     }
 }

我执行花服务器:
$ celery --workdir=spacegraphy/  --app=spacegraphy.celery:app flower

我访问 https://spacegraphy.choislaw.xyz/flower/ ,显示如下:

enter image description here

如果我点击任何链接,

enter image description here

我错过了什么?我是否将花卉服务器与应用程序服务器分开?

顺便说一句,在生产服务器上运行花服务器通常吗?

最佳答案

您需要将花 nginx conf 更改为:

location ~ ^/flower/? {
    rewrite ^/flower/?(.*)$ /$1 break;

    sub_filter '="/' '="/flower/';
    sub_filter_last_modified on;
    sub_filter_once off;

    # proxy_pass http://unix:/tmp/flower.sock:/;
    proxy_pass http://localhost:5555;
    proxy_redirect off;
    proxy_set_header Host $host;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_http_version 1.1;
}

关于Django:如何在生产模式下访问 celery 花页面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41241048/

相关文章:

python - pythonanywhere 媒体文件夹出现问题

Nginx 安装在 Mac OS X Lion 上。找不到 PCRE

angular - 使用 nginx "no such file or directory"容器化 Angular 应用程序

python - Celery池进程、任务以及系统进程和内存空间

mongodb - celery 与 mongoDB 的工作示例

python - heroku 上的美汤?

javascript - 为什么将我所有的 jquery 插件放入一个文件中不起作用?

php - Docker 最佳实践 : single process for a container

python - celery:在所有子任务的所有子任务运行后调用任务

Django 内容类型表 - 身份验证权限