gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 14:24:18 25 4
gpt4 key购买 nike

在开发模式(本地)下,真的很容易访问花页( 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com