Configuration for Django, Apache and Nginx

。_饼干妹妹 提交于 2019-12-04 03:29:51

The django docs you linked to do not suggest you use apache as a reverse proxy. They simply suggest you use a separate web server, so I'd say the docs are not clear on that subject -- they are not suggesting anything wrong.

My initial answer was assuming you had nginx as a reverse proxy because port 80 is the HTTP port, the one used when a browser attempts to go to a url with no port specified.

There are numerous complete guides to setting up nginx + apache via a quick google search but here is the gist for setting up nginx:

location / {
        # proxy / requests to apache running django on port 8081
        proxy_pass         http://127.0.0.1:8081/;
        proxy_redirect     off;
    } 

location /media/ { 
        # serve static media directly from nginx
        root   /srv/anuva_project/www/;
        expires 30d;
        break;
    }

All you need to do is remove the proxy lines from your apache configuration and add the proxy statements to your nginx.conf instead.

If you really want to serve your site from port 8081, you could potentially have nginx listen on port 8081 and have apache listen on a different port.

The point is, apache sits in some obscure port, only serving requests sent to it from nginx, while static file serving is handled by nginx.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!