django nginx setup issues -
in following trying configure http://uwsgi-docs.readthedocs.org/en/latest/tutorials/django_and_nginx.html
the following conf file below placed in project directory , have linked same in sites-enabled of nginx directory.
now when access http://127.0.0.1:8000/app1/files?path=/ end 502 bad gateway
, nginx error log says
2015/09/21 14:07:41 [error] 8023#0: *7 connect() failed (111: connection refused) while connecting upstream, client: 127.0.0.1, server: 127.0.0.1, request: "get / http/1.1", upstream: "uwsgi://127.0.0.1:8001", host: "127.0.0.1:8000"
but able access link http://127.0.0.1:8000/media/a.jpg doing wrong here , how can access django application
# mysite_nginx.conf # upstream component nginx needs connect upstream django { # server unix:///path/to/your/mysite/mysite.sock; # file socket server 127.0.0.1:8001; # web port socket (we'll use first) } # configuration of server server { # port site served on listen 8000; # domain name serve server_name 127.0.0.1; # substitute machine's ip address or fqdn charset utf-8; # max upload size client_max_body_size 75m; # adjust taste # django media location /media { alias /home/rajeev/django-test/mysite/media; # django project's media files - amend required } location /static { #alias /path/to/your/mysite/static; # django project's static files - amend required alias /home/rajeev/django-test/mysite/static/; # django project's static files - amend required } # finally, send non-media requests django server. location / { uwsgi_pass django; include /home/rajeev/django-test/mysite/conf/uwsgi_params; # uwsgi_params file installed } }
edit1: uwsgi_params file
uwsgi_param query_string $query_string; uwsgi_param request_method $request_method; uwsgi_param content_type $content_type; uwsgi_param content_length $content_length; uwsgi_param request_uri $request_uri; uwsgi_param path_info $document_uri; uwsgi_param document_root $document_root; uwsgi_param server_protocol $server_protocol; uwsgi_param request_scheme $scheme; uwsgi_param https $https if_not_empty; uwsgi_param remote_addr $remote_addr; uwsgi_param remote_port $remote_port; uwsgi_param server_port $server_port; uwsgi_param server_name $server_name;
you've missed 1 point in tutorial. configuration of uwsgi nginx different configuration checking in browser if uwsgi working not used port, protocol.
when deploying uwsgi nginx, --http
should replaced --socket
. change, nginx understand output uwsgi server, browser won't.
configuration browser (to check if uwsgi working) can work nginx also, must use proxy_pass
instead of uwsgi_pass
in nginx, , using not recommended, uwsgi protocol faster , better communication between web server , uwsgi server.
Comments
Post a Comment