[問題] Django + uwsgi + lighttpd

看板Python作者 (oiga por favor)時間4年前 (2019/07/08 23:35), 編輯推噓1(104)
留言5則, 3人參與, 4年前最新討論串1/1
最近在自學 Django rest framework 並嘗試把它搭配到目前已有的 lighttpd 運行 網路上大部分都是資源都是搭配 nginx 自己摸索一下後總算是運行起來(?) 但是有點奇怪,我的api http://ip-address/api/faceitems python3 manage.py runserver 0.0.0.0:8000 的情況下 ip-address:8000/api/faceitems 是正常運作的 但如果是透過 uwsgi + lighttpd 運行 ip-address/api/faceitems 卻會404 not found 從django 的 debug message看起來是有進去的 https://i.imgur.com/eYt9koz.jpg
但不知道為什麼current path 會變成少了/api 導致404 如果在 /api 前面加上任意路徑 例如 123/api/faceitems 就可以了! 感覺就是會吃掉一段 /XXX/ 不確定是我運行方式有誤? 或是配置檔不正確 lighttpd.conf : server.modules += ( "mod_scgi" ) $HTTP["url"] =~ "^/api/" { scgi.protocol = "uwsgi" scgi.server = ( "/" => (( "host" =>"127.0.0.1","port"=>"8000","check-local"=>"disable" )), ) } uwsgi : uwsgi --socket 127.0.0.1:8000 --module mysite.wsgi django rest framework 的部分是參照官網和下面的教學設定的 https://github.com/twtrubiks/django-rest-framework-tutorial 請問是哪裡做錯了呢? 超級新手 還請各位不吝指教 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.45.99.71 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1562600139.A.B9C.html

07/08 23:53, 4年前 , 1F
我是用 django + nginx + uwsgi ,蠻複雜是真的
07/08 23:53, 1F

07/09 16:43, 4年前 , 2F
你可以用uwsgi先直接開個測試server去看是不是lighthttpd的
07/09 16:43, 2F

07/09 16:43, 4年前 , 3F
問題
07/09 16:43, 3F

07/09 16:44, 4年前 , 4F
不過lighttpd我就真的不熟了
07/09 16:44, 4F

07/10 11:01, 4年前 , 5F
直接測試是沒問題的 加上lighttpd 就異常
07/10 11:01, 5F
文章代碼(AID): #1T8sBBkS (Python)