问题原文
原帖链接 · Olivier H · CC BY-SA 3.0
Here's what my environment looks like:
- REST api (django), running over WSGI (mod_wsgi) on port
http://server:8107/api - static files for the API site (i have some admin pages), in a directory, say
/opt/wsgi/staticfiles/subdomain - Web application (expressjs), running over pm2/nodejs, on
http://server:3002/
I need to group all this under a virtualhost on port 80 as follows:
- http://subdomain.server/api : the rest API
- http://subdomain.server/api/static : the static files needed by the API site
- http://subdomain.server/ : the web application
Here is the relevant part of the configuration:
<VirtualHost *:80>
ServerName subdomain.server
ServerAlias subdomain.server.local
Alias /api/static/ /opt/wsgi/staticfiles/subdomain/
<Directory /opt/wsgi/staticfiles/subdomain/ >
Order Allow,Deny
Allow from All
Options -Indexes
IndexOptions Charset=UTF-8
</Directory>
ProxyPass /api http://127.0.0.1:8107/api
ProxyPassReverse /api http://127.0.0.1:8107/api
ProxyPass / http://127.0.0.1:3002/
ProxyPassReverse / http://127.0.0.1:3002/
</VirtualHost>
Now, when I try to access a static resource (let's say for example /api/static/js/jquery.js) i find that the url is not resolved first by the Alias directive, but rather passed to the WSGI app (/api), which then obviously fires a 404 error.
Re-ordering the directives does not seem to have any effect.
What should I change to ensure HTTPD will serve /api/static before anything else?
*EDIT*: I run Apache HTTPD 2.2.15 under a CentOS 6.5 distro
已采纳解答
原帖链接 · Guillaume Fenollar · CC BY-SA 3.0
The following conf is what you are looking for :
ProxyPass /api/static !
It tells Apache to not take this path into account when routing stuff to your proxied application, so it can be dealt with other kind of access (here your Alias directive).
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
