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

  • NGINX Cookbook
  • Tim Butler
  • 164字
  • 2021-07-03 00:04:28

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.

主站蜘蛛池模板: 札达县| 道真| 红原县| 敦化市| 凌海市| 奎屯市| 新野县| 河北区| 大化| 安义县| 亚东县| 通化市| 松滋市| 南投市| 徐州市| 重庆市| 田东县| 四子王旗| 淅川县| 陕西省| 定西市| 灌云县| 兴化市| 林州市| 石泉县| 高雄县| 富蕴县| 麦盖提县| 天水市| 墨脱县| 囊谦县| 明溪县| 上栗县| 龙南县| 偏关县| 互助| 葵青区| 金堂县| 克东县| 古浪县| 当涂县|