apache - 无法配置 Apache 为 CherryPy 应用程序提供静态内容。我做错了什么?

标签 apache static cherrypy mod-proxy mod-ssl

我使用 Mod_Proxy 和 Mod_SSL 配置了 Apache 2.2.15,并在 RHEL 6.3 上为 CherryPy Web 应用程序提供服务。我唯一遇到困难的是让 Apache 为网站的静态内容(*.js、*.css、*.jpg)提供服务。这是我的 VirtualHost 条目...

<VirtualHost mydomain.com:443>
ServerAdmin support@mydomain.com
ServerName mydomain.com
ProxyPreserveHost On
SSLProxyEngine On
DocumentRoot /var/www/html/mydomain

SSLEngine on
SSLCertificateKeyFile /etc/ssl/myserver.key
SSLCertificateFile /etc/ssl/mydomain_com.crt
SSLCertificateChainFile /etc/ssl/mydomain_com.ca-bundle

# this prevents the follow URL path from being proxied
ProxyPass static/ !

# setup the proxy
<Proxy *>
    Order allow,deny
    Allow from all
</Proxy>
ProxyPass / http://www.mydomain.com:8080/
ProxyPassReverse / http://www.mydomain.com:8080/
</VirtualHost>

例如,我的 css 文件的路径如下...
/var/www/html/mydomain/static/style.css

由于我在导航到时强制整个站点处于 https 中
https://www.mydomain.com/static/style.css

或者
http://www.mydomain.com/static/style.css

我的浏览器告诉我找不到页面 (404)。谁能看到我做错了什么?

编辑:
看来 Apache 仍在代理/static ......我在访问我的 Apache 访问日志中的/static/style.css 时发现了这个重定向......
xxx.xxx.xxx.xxx - - [17/Sep/2012:08:46:06 -0400] "GET /static/style.css HTTP/1.1" 301 337 "https://www.mydmain.com/Home/" "Mozilla/5.0 (X11; Linux x86_64; rv:10.0.7) Gecko/20120826 Firefox/10.0.7"

有谁知道为什么会这样?

提前致谢!

安德鲁

最佳答案

尝试在 ProxyPass 之前为您的静态文件夹添加别名。它对我来说就像冠军一样,

Alias /static/ /var/www/html/mydomain/static/

关于apache - 无法配置 Apache 为 CherryPy 应用程序提供静态内容。我做错了什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12426569/

相关文章:

c++ - 类中的静态函数,内存将如何处理?

java - 在构造函数中调用另一个类的非静态方法

python - cherrypy 两台服务器不同的端口

python - Cherrypy 使用 cxfreeze 打包时找不到 wsgiserver 模块

ruby-on-rails - 如何在单个IP(Apache + Passenger)上部署多个rails应用程序?

python - Apache mod_wsgi 和 python 2.7

c# - 如何在 C# 中创建具有静态工厂方法的基类?

python - 使用 jQuery 从 Web 服务器获取数据

regex - .htaccess 仅当路径包含数字和字母时才重写

apache - 在 CentOs 7 上使用 yum 没有可用的包 httpd