這是django1.7 的view代碼:
def wx_serve(request):
return HttpResponse('welcome')
這是uwsgi2.0.8響應:
[pid: 3191|app: 0|req: 2/2] **.*.**.** () {36 vars in 687 bytes} [Wed Jan 7 16:11:11 2015] GET /service/toher/ => generated 7 bytes in 1 msecs (HTTP/1.1 200) 2 headers in 88 bytes (1 switches on core 1)
[pid: 3189|app: 0|req: 1/3] **.*.**.** () {42 vars in 686 bytes} [Wed Jan 7 16:11:49 2015] POST /service/toher/ => generated 2650 bytes in 35 msecs (HTTP/1.1 403) 2 headers in 80 bytes (1 switches on core 0)
購買的阿裡雲服務器,使用nginx1.7.4轉發給uwsgi處理,nginx和uwsgi都是常規配置,但為何針對
get請求,服務器響應很正常,卻一直拒絕post請求呢?
問題暫時解決了! 在setting裡面注釋掉django.middleware.csrf.CsrfViewMiddleware即可。
謝謝@oyljerry的啟發!