apache reverseproxy not working @noob

2019-09-18 06:25发布

问题:

I'm kinda new to server deployment stuff, so please bear with me for this noob question. My webapp run on apache while I'm serving the static files from nginx. So far so good. I want that users should be able to access some static files by accessing the apache directly( a case for reverseproxy). Here is my apache site file.

ServerName enpass.djangoserver
DocumentRoot /srv/www/enpass

ProxyRequests Off

<Proxy *>
Order deny,allow
Allow from all
</Proxy>


<Directory /srv/www/enpass>
    Order allow,deny
    Allow from all
</Directory>

ProxyPass /nginx/ http://localhost/media/
ProxyPassReverse /nginx/ http://localhost/media/

My webapp is based on django framework. Whenever i try to access something like http://enpass.djangoserver/nginx/foo, instead of data from nginx, I get an error message from my webapp(django), that /nginx is not a defined URL. Whats wrong with my configuration files? It could be an issue with priority of URL requests, but I have no idea how to proceed. Disclaimer: I posted this question a while ago at serverfault too. So don't shoot me.

回答1:

Have you checked this?

If I am not mistaken you are trying to use Apache+nginx the wrong way. Nginx should be the first one serving requests and pass back to apache/django the non-static ones. Otherwise there is not much to gain from nginx...