天天看點

nginx Django .conf 配置

server {
        #虛拟主機監聽端口号
        listen       8002;
        #虛拟主機 監聽IP
        server_name  你的外網IP;
    
    root html;

        #charset koi8-r;

        #虛拟主機日志列印路徑
        access_log  /root/python/source-alpha/product/logs/host.access.log  main;

        #虛拟主機所有攔截交給 django 處理
        location / {
         include        uwsgi_params;
        #注意,此處IP和端口号要與 django 啟動服務IP和端口号一至
         uwsgi_pass     172.16.0.4:8001;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
        # 設定Django 靜态檔案通路
        location /static/ {
            alias  /root/python/product/static/;
            #index  index.html index.htm;
        }
        # 設定Django 靜态檔案通路
        location /files/ {
            alias  /root/python/product/files/;
        }


    }           

複制

【注】

當我們更改配置檔案後記住一定要

nginx -t

一定要測試一下配置檔案格式是否正确

nginx 證書配置