官术网_书友最值得收藏!

How it works....

The first configuration item we tweak is the favicon:

location = /favicon.ico { access_log off; log_not_found off; } 

There's a very famous story of Instagram's first deployment (where they had 10,000 users in the first day) and the load that a missing favicon generated (since Django had to produce the 404 error) caused significant scaling issues.

Next, we serve any of the uploaded and static media directly via NGINX:

location /static|/media { 
    root /var/www/djangodemo/; 
} 

These directories are mapped via the STATIC_ROOT and MEDIA_ROOT configuration lines within the settings.py file for Django. NGINX is very efficient at serving static media, so serving it directly produces as little overhead as possible.

We then map app's all other URL calls via the uwsgi protocol:

location / { 
    include         uwsgi_params; 
    uwsgi_pass      127.0.0.1:8000; 
} 

The uWSGI project has a native protocol (called uwsgi and in lower case), which is built into NGINX by default. It's a binary protocol designed to be highly efficient and scalable.

主站蜘蛛池模板: 杭锦后旗| 德庆县| 南召县| 株洲市| 海淀区| 富阳市| 建阳市| 礼泉县| 沧州市| 通州区| 昭苏县| 唐海县| 突泉县| 翼城县| 怀仁县| 临洮县| 灵璧县| 渝中区| 廉江市| 麻栗坡县| 黄浦区| 盖州市| 凤台县| 剑河县| 苍南县| 平泉县| 新和县| 甘德县| 策勒县| 林周县| 邵武市| 宜兰县| 乌拉特中旗| 乌拉特中旗| 神农架林区| 霍林郭勒市| 汕头市| 兴安盟| 铁岭市| 汶上县| 雷山县|