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

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

環(huán)境:
OS X 10.8.5
django 1.6
python 2.7.2
先貼一下我的配置

[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;
    }
}

配置基本都是按照下面這兩個教程來的
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 的話,會報 502 錯誤,
uwsgi里面一直都是下面這樣,看不到有請求到來。

*** 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 的話,都會報 400 錯誤。
但是 uwsgi 里面可以看到有請求到來。

*** 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)

煩了兩天了,不知道應(yīng)該怎么解決...


另外想問一下 nginx 中的 include uwsgi_params; 作用是什么?
我發(fā)現(xiàn)如果沒有這個的話,uwsgi就會報下面的錯誤:

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'
伊謝爾倫
伊謝爾倫

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

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

如果用 nginx 和 uwsgi 都用 socket 的話,會報 502 錯誤

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

如果都用 127.0.0.1:3031 的話,都會報 400 錯誤。

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

提供一個可能性的猜測:

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)站素材
前端模板