作家
登录

如何在Linux上使用Nginx和Gunicorn托管Django应用

作者: 来源: 2017-04-20 09:40:38 阅读 我要评论

  •     ssl_certificate /etc/letsencrypt/live/yourwebsite.com/fullchain.pem; 
  •     ssl_certificate_key /etc/letsencrypt/live/yourwebsite.com/privkey.pem; 
  •     # 设置根目次 
  •     root /var/www/yourvirtualenv/yourproject; 
  •     # 为 Nginx 指定静态文件路径 
  •     location /static/ { 
  •         # Autoindex the files to make them browsable if you want 
  •         autoindex on
  •         # The location of your files 
  •         alias /var/www/yourvirtualenv/yourproject/static/; 
  •         # Set up caching for your static files 
  •         expires 1M; 
  •         access_log off
  •         add_header Cache-Control "public"
  •         proxy_ignore_headers "Set-Cookie"
  •     } 
  •     # 为 Nginx 指定你上传文件的路径 
  •     location /media/ { 
  •         Autoindex if you want 
  •         autoindex on
  •         # The location of your uploaded files 
  •         alias /var/www/yourvirtualenv/yourproject/media/; 
  •         # Set up aching for your uploaded files 
  •         expires 1M; 
  •         access_log off
  •         add_header Cache-Control "public"
  •         proxy_ignore_headers "Set-Cookie"
  •     } 
  •     location / { 
  •         # Try your static files firstthen redirect to Gunicorn 
  •         try_files $uri @proxy_to_app; 
  •     } 
  •     # 将请求传递给 Gunicorn 
  •     location @proxy_to_app { 
  •         proxy_set_header X-Forwarded-For

      推荐阅读

      如何在Ubuntu和Linux Mint上启用桌面共享

    桌面共享是指经由过程图形终端仿真谱钥淦算机桌面上实现远查拜访和长途协作的技巧。桌面共享许可两个或多个连接到收集的计算机用户在不合地位对同一个文件进行操作。在 Ubuntu 和 Linux M>>>详细阅读


    本文标题:如何在Linux上使用Nginx和Gunicorn托管Django应用

    地址:http://www.17bianji.com/lsqh/34866.html

  • 关键词: 探索发现

    乐购科技部分新闻及文章转载自互联网,供读者交流和学习,若有涉及作者版权等问题请及时与我们联系,以便更正、删除或按规定办理。感谢所有提供资讯的网站,欢迎各类媒体与乐购科技进行文章共享合作。

    网友点评
    自媒体专栏

    评论

    热度

    精彩导读
    栏目ID=71的表不存在(操作类型=0)