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

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.

主站蜘蛛池模板: 莱州市| 韩城市| 巍山| 民勤县| 合川市| 呼玛县| 红原县| 黄石市| 同德县| 南川市| 楚雄市| 东乌珠穆沁旗| 衡阳市| 磐石市| 苏尼特左旗| 深州市| 贵定县| 城步| 大石桥市| 贵港市| 廊坊市| 明水县| 汪清县| 普兰县| 临洮县| 雷山县| 成都市| 洪江市| 武鸣县| 开封县| 象州县| 聊城市| 武隆县| 濉溪县| 调兵山市| 丰城市| 五大连池市| 吕梁市| 汝南县| 临湘市| 洮南市|