apache反向代理不工作@noob
我对服务器部署有点陌生,所以请耐心等待我回答这个菜鸟问题。我的 web 应用程序在 apache 上运行,同时我从 nginx 提供静态文件。到目前为止,一切都很好。我希望用户应该能够通过直接访问 apache 来访问一些静态文件(反向代理的情况)。这是我的 apache 站点文件。
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/
我的网络应用程序基于 django 框架。每当我尝试访问诸如 http://enpass.djangoserver/nginx/foo 之类的内容时,而不是来自nginx,我从我的 webapp(django) 收到一条错误消息,/nginx 不是定义的 URL。 我的配置文件有什么问题吗?这可能是 URL 请求优先级的问题,但我不知道如何继续。 免责声明:我不久前也在 serverfault 上发布了这个问题。所以别开枪打我。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您检查过这个吗?
如果我没记错的话,您正在尝试以错误的方式使用 Apache+nginx。
Nginx 应该是第一个服务请求并将非静态请求传递回 apache/django 的服务器。否则,从 nginx 中获得的收益并不多......
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...