HHVM should process all files as PHP in fastcgi mode by default
I have HHVM 3.3.1 running as a fastcgi server with nginx serving requests. I want CSS and JS to also be treated as PHP. This is our best option for various reasons and various alternatives do not work great for us.
I configured nginx to send all php, css, and js requests to hhvm.
By default, HHVM will receive the request, but does no processing on the file, and only returns the raw contents of the file. (As an aside, nginx will only deliver the raw contents of that file after a pause -- perhaps some kind of timeout. This may be a configuration problem or separate hhvm bug. I did not investigate that issue much.)
After a bit of poking around, I learned that this can be fixed by adding the following to the config.hdf
PhpFile {
Extensions {
css = application/x-php
js = application/x-php
}
}
I did not have a config.vdf and was using the default ini files shipped in the Ubuntu package, so I had to create this file and add it as a --config command line option.
I suggest that hhvm should process all extensions as a php file when operating as a fastcgi server. I would not send the request to hhvm's fastcgi server if I did not want it to process the request as PHP.
Sorry - given we support people using proxypass or similar to redirect entire subtrees to HHVM (so, serving static resources via HHVM), this would be a huge backwards-compatibility break.
Given that many PHP projects store user uploads inside the docroot, this behavior would also likely be a major security issue.
Maybe HHVM could at least provide some sort of wildcard, like PhpFile.Extensions.*, that would ease @apaloma's usecase.
I think using such an option is generally a bad idea, but cc @JoelMarcey.
@paulbiss: I definitely agree, but if some people desire such behavior. Maybe a flag like bool PhpFile.InterpretAllFilesByDefault = false (with an exclamation mark in docs) would be an easy solution for them.
I'll kick it around and see what everyone thinks, I'm still not wild about it, it encourages poor practices.
I do admit I'm not familiar with using proxypass, so the security concern did not cross my mind. I'm used to specifying the file types and locations that contain PHP code in the Apache/nginx config. It does seem unfortunate to diverge from php-fpm behavior in this regard.