ini django的nginx配置

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ini django的nginx配置相关的知识,希望对你有一定的参考价值。

upstream example {
  # fail_timeout=0 means we always retry an upstream even if it failed
  # to return a good HTTP response (in case the Unicorn master nukes a
  # single worker for timing out).

  server unix:/webapps/example.com/gunicorn.sock fail_timeout=0;
}

server{
	listen 80;
	server_name example.com;
	client_max_body_size 4G;
	access_log /webapps/example.com/logs/nginx-access.log;
	error_log /webapps/example.com/logs/nginx-error.log;

		
	# Robot.txt configuration 
  # developers work on robot.txt more so it is suitable to push inside source code.
      	location /robots.txt {
      	  alias /webaps/example.org/robots.txt;
	} 
	# Static assets configuration
 	location /static/ {
        alias   /webapps/example.com/master/src/assets/;
        expires 30d;
    	}
	
	# Media configuration
	location /media/ {
        alias   /webapps/example.com/master/src/media/;
        expires 30d;
    	}	
        
        # Need to review
      location / {
    	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
   	  proxy_set_header Host $http_host;
    	proxy_redirect off;
   	  if (!-f $request_filename) {
        	proxy_pass http://example; #app name
        	break;
    		}
	} 
	
        # Favicon configuration
        location /favicon.ico {
    	 alias /webapps/example.com/master/src/assets/img/favicon.ico;
	} 
         
        # Prevent hidden files being serverd
	location ~ /\. { access_log off; log_not_found off; deny all; } 
        
	# Error page configuration 
        error_page 500 502 503 504 /500.html;
    	location = /500.html {
        root /webapps/example.com/master/src/static/;
   	 }
}

以上是关于ini django的nginx配置的主要内容,如果未能解决你的问题,请参考以下文章

centos7.3部署django用uwsgi和nginx[未解决]

django+vue前后端分离项目部署

uwsgi+django+nginx

nginx+uwsgi02---django部署

ini django_nginx.conf

Django uwsgi+nginx+supervisor部署