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 证书配置

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

友情链接更多精彩内容