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

  • 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.

主站蜘蛛池模板: 镇江市| 乌兰县| 江都市| 客服| 保康县| 武清区| 仪征市| 青岛市| 余庆县| 顺平县| 集贤县| 邵东县| 江川县| 白银市| 滕州市| 广州市| 太康县| 黑龙江省| 洛宁县| 桑植县| 云浮市| 丰都县| 白沙| 鄯善县| 洛南县| 额敏县| 广河县| 深州市| 乌什县| 招远市| 姚安县| 开江县| 和静县| 永泰县| 大埔区| 西吉县| 松阳县| 连山| 康定县| 南开区| 永州市|