国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

nginx + uwsgi 部署 django 失敗,不是 400 就是 502 ....
伊謝爾倫
伊謝爾倫 2017-05-16 17:28:00
0
1
915

環(huán)境:
OS X 10.8.5
django 1.6
python 2.7.2
先貼一下我的設(shè)定

[uwsgi]
# socket          = /Users/scarlex/Projects/venv/mysite/white.sock
socket          = 127.0.0.1:3031
chdir           = /Users/scarlex/Projects/venv/mysite/
module          = sakuramai.wsgi:application
home            = /Users/scarlex/Projects/venv
env             = DJANGO_SETTINGS_MODULE=sakuramai.settings
static_files    = false

master          = true
processes       = 5
chmod-socket    = 664
vacuum          = true
stats = 127.0.0.1:9191
upstream white {
    server localhost:3031;
    # server unix:///Users/scarlex/Projects/venv/mysite/white.sock;
}

server {
    listen       80;
    server_name  mysite.com localhost;
    charset utf-8;

    location /static/ {
        alias /Users/scarlex/Projects/venv/mysite/static/
        expires 30d;
    }

    location / {
        uwsgi_pass white;
        include uwsgi_params;
        uwsgi_param UWSGI_SCRIPT django_wsgi;
    }
}

設(shè)定基本上都是按照下面這兩個(gè)教學(xué)來的
https://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html
https://docs.djangoproject. com/en/1.6/howto/deployment/wsgi/uwsgi/

如果用 nginx 和 uwsgi 都用 socket 的話,會(huì)報(bào) 502 錯(cuò)誤,
uwsgi裡面一直都是下面這樣,看不到有請(qǐng)求到來。

*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 88475)
spawned uWSGI worker 1 (pid: 88476, cores: 1)
spawned uWSGI worker 2 (pid: 88477, cores: 1)
spawned uWSGI worker 3 (pid: 88478, cores: 1)
spawned uWSGI worker 4 (pid: 88479, cores: 1)
spawned uWSGI worker 5 (pid: 88480, cores: 1)
*** Stats server enabled on 127.0.0.1:9191 fd: 17 ***

如果都用 127.0.0.1:3031 的話,都會(huì)報(bào) 400 錯(cuò)誤。
但是 uwsgi 裡面可以看到有請(qǐng)求到來。

*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 88497)
spawned uWSGI worker 1 (pid: 88498, cores: 1)
spawned uWSGI worker 2 (pid: 88499, cores: 1)
spawned uWSGI worker 3 (pid: 88500, cores: 1)
spawned uWSGI worker 4 (pid: 88501, cores: 1)
spawned uWSGI worker 5 (pid: 88502, cores: 1)
*** Stats server enabled on 127.0.0.1:9191 fd: 17 ***
[pid: 88500|app: 0|req: 1/1] 127.0.0.1 () {42 vars in 727 bytes} [Mon Feb 24 15:47:56 2014] GET / => generated 26 bytes in 406 msecs (HTTP/1.1 400) 1 headers in 53 bytes (1 switches on core 0)
[pid: 88501|app: 0|req: 1/2] 127.0.0.1 () {40 vars in 658 bytes} [Mon Feb 24 15:47:57 2014] GET /favicon.ico => generated 26 bytes in 190 msecs (HTTP/1.1 400) 1 headers in 53 bytes (1 switches on core 0)

煩了兩天了,不知道該怎麼解決...


另外想問 nginx 中的 include uwsgi_params; 作用是什麼?
我發(fā)現(xiàn)如果沒有這個(gè)的話,uwsgi就會(huì)報(bào)下面的錯(cuò)誤:

Traceback (most recent call last):
  File "/Users/scarlex/Projects/Python-projects/skm2014/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 196, in __call__
    request = self.request_class(environ)
  File "/Users/scarlex/Projects/Python-projects/skm2014/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 91, in __init__
    self.method = environ['REQUEST_METHOD'].upper()
KeyError: u'REQUEST_METHOD'
伊謝爾倫
伊謝爾倫

小伙看你根骨奇佳,潛力無限,來學(xué)PHP伐。

全部回覆(1)
我想大聲告訴你

如果用 nginx 和 uwsgi 都用 socket 的話,會(huì)報(bào) 502 錯(cuò)誤

nginx報(bào)502,表示upstream設(shè)定有誤或upstream指向的server報(bào)錯(cuò)。 unix:///Users/scarlex/Projects/venv/mysite/white.sock寫法錯(cuò)誤,多了兩個(gè)斜杠,正確的是unix:/Users/scarlex/Projects/venv/mysite/white.sock。從題主貼出的uwsgi配置來看,chmod-socket = 664可能不當(dāng),嘗試設(shè)為chmod-socket = 666。nginx一般是以http用戶啟動(dòng)的,664可能無權(quán)寫入white.sock。

如果都用 127.0.0.1:3031 的話,都會(huì)報(bào) 400 錯(cuò)誤。

這跟nginx無關(guān)了,純粹是uwsgi的配置或是django配置有誤(如果是自身的腳本原始碼出錯(cuò)應(yīng)該報(bào)5xx)。如果可能貼出django的settings.py吧。

提供一個(gè)可能性的猜測(cè):

Finally, if DEBUG is False, you also need to properly set the ALLOWED_HOSTS setting. Failing to do so will result in all requests being returned as “Bad Request (400)”

https://docs.djangoproject.com/en/1.6/ref/settings/#std%3asetting-ALLOWED_HOSTS

最新下載
更多>
網(wǎng)站特效
網(wǎng)站源碼
網(wǎng)站素材
前端模板