How to install Django on nginx reverse proxy server ~

Source: Internet
Author: User
Tags install django nginx reverse proxy
‘‘‘server {    listen         12345;     server_name    10.10.10.132;    charset UTF-8;    client_max_body_size 75M;    location /static {        expires 30d;        autoindex on;         add_header Cache-Control private;        alias /home/zhangsan/git/nginxdemo/nginxdemo/static/;    }    location / {         include uwsgi_params;        uwsgi_pass 10.10.10.132:54321;        uwsgi_read_timeout 2;    }   }‘‘‘

When you browse the Web page and find the answer, you may encounter the problem of planning static pages to write dead paths when using Django, this is indeed the reason why the uwsgi module cannot be correctly used on my own nginx server and the Django program cannot run properly. But should static files be written to death like this?

Hard coding is never a good way to Process Code. It will reduce the flexibility of your program and it feels appropriate to do so.

import os.pathimport posixpathPROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), ‘..‘)STATIC_ROOT = os.path.join(PROJECT_ROOT, ‘static‘)

I am a little sleepy. I will find time tomorrow to list the advantages of this writing method and the knowledge involved.

How to install Django on nginx reverse proxy server ~

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.