2016-12-20 35 views
1

在開發模式(本地)中,訪問花頁非常容易(http://localhost:5555Django:如何在生產模式下訪問芹菜花頁面?

但是在生產模式下,很難訪問花頁面。

我想以這樣的URL訪問儀表盤花頁:
https://spacegraphy.choislaw.xyz/flower/(域名:choislaw.xyz)

我refered 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

我錯過了什麼?我是否將花朵服務器與應用服務器分開?

順便說一句,在生產服務器上運行花卉服務器是否正常?

+0

靜態文件和位置/任務沒有設置/ – Jinje

+0

我怎樣才能應對它? – user3595632

+0

通常在生產服務器上運行花卉服務器嗎? 對我而言,只能用於維護目的。 – Jinje

回答

0

你可以運行--url前綴花=花

0

你需要改變花的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; 
}