My python files are fun by fcgi without a problem, but my static content is producing 404 errors.
My fastcgi.conf:
server.modules += ( "mod_fastcgi" )
fastcgi.server = ("/" =>
((
"socket" => "/tmp/webxyz-fcgi.sock",
"bin-path" => "/opt/local/www/xyz/webxyz.fcgi",
"check-local" => "disable",
"max-procs" => 1
))
)
alias.url = (
"/static" => "/opt/local/www/xyz/app/static"
)
url.rewrite-once = (
#"^(/static($|/.*))$" => "$1",
"^(/static.*)$" => "$1",
"^(/.*)$" => "/webxyz.fcgi$1"
)
I have some debugging turned on:
debug.log-request-handling = "enable"
debug.log-request-header-on-error = "enable"
debug.log-file-not-found = "enable"
(though oddly file not found doesn't seem to do anything...)
Here's what I see in the error.log for one of the static files - all the others produce similar output (the ellipses below are a bunch more uninformative condition blocks that vary only in line number):
2014-04-27 15:20:24: (response.c.340) Request-URI : /static/bower_components/x-editable/dist/bootstrap3-editable/js/bootstrap-editable.js
2014-04-27 15:20:24: (response.c.341) URI-scheme : http
2014-04-27 15:20:24: (response.c.342) URI-authority : 75.101.102.25:8080
2014-04-27 15:20:24: (response.c.343) URI-path (raw) : /static/bower_components/x-editable/dist/bootstrap3-editable/js/bootstrap-editable.js
2014-04-27 15:20:24: (response.c.344) URI-path (clean): /static/bower_components/x-editable/dist/bootstrap3-editable/js/bootstrap-editable.js
2014-04-27 15:20:24: (response.c.345) URI-query :
2014-04-27 15:20:24: (configfile-glue.c.579) === start of condition block ===
2014-04-27 15:20:24: (configfile-glue.c.537) 1 (cached) result: false
2014-04-27 15:20:24: (response.c.249) run condition
2014-04-27 15:20:24: (configfile-glue.c.579) === start of condition block ===
2014-04-27 15:20:24: (configfile-glue.c.273) 2 global/HTTPurl=~\.pdf$ nej
2014-04-27 15:20:24: (configfile-glue.c.530) 1 (uncached) result: unknown
...
2014-04-27 15:20:24: (configfile-glue.c.579) === start of condition block ===
2014-04-27 15:20:24: (configfile-glue.c.467) HTTP["url"] ( /static/bower_components/x-editable/dist/bootstrap3-editable/js/bootstrap-editable.js ) compare to \.pdf$
2014-04-27 15:20:24: (configfile-glue.c.530) 1 (uncached) result: false
2014-04-27 15:20:24: (configfile-glue.c.579) === start of condition block ===
2014-04-27 15:20:24: (configfile-glue.c.537) 1 (cached) result: false
2014-04-27 15:20:24: (response.c.339) -- splitting Request-URI
2014-04-27 15:20:24: (response.c.340) Request-URI : /static/bower_components/x-editable/dist/bootstrap3-editable/js/bootstrap-editable.js
2014-04-27 15:20:24: (response.c.341) URI-scheme : http
2014-04-27 15:20:24: (response.c.342) URI-authority : 75.101.102.25:8080
2014-04-27 15:20:24: (response.c.343) URI-path (raw) : /static/bower_components/x-editable/dist/bootstrap3-editable/js/bootstrap-editable.js
2014-04-27 15:20:24: (response.c.344) URI-path (clean): /static/bower_components/x-editable/dist/bootstrap3-editable/js/bootstrap-editable.js
2014-04-27 15:20:24: (response.c.345) URI-query :
2014-04-27 15:20:24: (configfile-glue.c.579) === start of condition block ===
2014-04-27 15:20:24: (configfile-glue.c.537) 1 (cached) result: false
2014-04-27 15:20:24: (configfile-glue.c.579) === start of condition block ===
2014-04-27 15:20:24: (configfile-glue.c.537) 1 (cached) result: false
2014-04-27 15:20:24: (mod_access.c.135) -- mod_access_uri_handler called
2014-04-27 15:20:24: (configfile-glue.c.579) === start of condition block ===
2014-04-27 15:20:24: (configfile-glue.c.537) 1 (cached) result: false
2014-04-27 15:20:24: (configfile-glue.c.579) === start of condition block ===
2014-04-27 15:20:24: (configfile-glue.c.537) 1 (cached) result: false
2014-04-27 15:20:24: (mod_fastcgi.c.3626) handling it in mod_fastcgi
2014-04-27 15:20:24: (response.c.473) -- before doc_root
2014-04-27 15:20:24: (response.c.474) Doc-Root : /opt/local/www/htdocs
2014-04-27 15:20:24: (response.c.475) Rel-Path : /static
2014-04-27 15:20:24: (response.c.476) Path :
2014-04-27 15:20:24: (response.c.524) -- after doc_root
2014-04-27 15:20:24: (response.c.525) Doc-Root : /opt/local/www/htdocs
2014-04-27 15:20:24: (response.c.526) Rel-Path : /static
2014-04-27 15:20:24: (response.c.527) Path : /opt/local/www/htdocs/static
2014-04-27 15:20:24: (configfile-glue.c.579) === start of condition block ===
2014-04-27 15:20:24: (configfile-glue.c.537) 1 (cached) result: false
2014-04-27 15:20:24: (response.c.544) -- logical -> physical
2014-04-27 15:20:24: (response.c.545) Doc-Root : /opt/local/www/htdocs
2014-04-27 15:20:24: (response.c.546) Basedir : /opt/local/www/xyz/app/static
2014-04-27 15:20:24: (response.c.547) Rel-Path : /static
2014-04-27 15:20:24: (response.c.548) Path : /opt/local/www/xyz/app/static
2014-04-27 15:20:24: (configfile-glue.c.579) === start of condition block ===
2014-04-27 15:20:24: (configfile-glue.c.537) 1 (cached) result: false
2014-04-27 15:20:24: (response.c.249) run condition
2014-04-27 15:20:24: (configfile-glue.c.579) === start of condition block ===
2014-04-27 15:20:24: (configfile-glue.c.273) 2 global/HTTPurl=~\.pdf$ nej
...
The last path it's looking at, /opt/local/www/xyz/app/static is my static directory, and contains bower_components/x-editable/dist/bootstrap3-editable/js/bootstrap-editable.js
I'm not sure why it's not being found - the permissions are fine:
sudo -u www cat /opt/local/www/xyz/app/static/bower_components/x-editable/dist/bootstrap3-editable/js/bootstrap-editable.js
works as expected.
Any guidance or suggestions appreciated.
Ok.
So reading this post, I see that my use of the werkzeug.contrib.fixers.CGIRootFix has led me to define the scope of my fcgi as "/", which takes precedence over the url and rewrite rules for "/static". Wrapping the fcgi server in a condition to exclude requests for urls beginning with "/static" fixes the problem with no static content being served.
Here's the working fastcgi.conf:
server.modules += ( "mod_fastcgi" )
$HTTP["url"] !~ "^/static" {
fastcgi.server = ("/" =>
((
"socket" => "/tmp/webpdb-fcgi.sock",
"bin-path" => "/opt/local/www/xyz/webxyz.fcgi",
"check-local" => "disable",
"max-procs" => 1
))
)
}
alias.url = (
"/static" => "/opt/local/www/xyz/app/static"
)
url.rewrite-once = (
#"^(/static($|/.*))$" => "$1",
"^(/static.*)$" => "$1",
"^(/.*)$" => "/webxyz.fcgi$1"
)