0

I'm trying to use Puppet and a Nginx plugin to manage a virtual host config file. I have everything working, but now that I need to add some rewrite rules I'm running into issues.

I know I can use syntax like the line below to add a simple rule...

location_cfg_append => { 'rewrite' => '^ https://$server_name$request_uri? permanent' },

but I'm totally not getting how to use a slightly more complex set up such as

if (!-e $request_filename){
  rewrite ^(.*)$ /index.php break;
}
andrewvnice
  • 157
  • 1
  • 1
  • 6

1 Answers1

0

Your example should not be a rewrite at all. It should be the last entry in the try_files directive. For instance:

server {
    #.....stuff.....
    try_files $uri $uri/ /index.php;

Your puppet module seems to support a try_files parameter in nginx::resource::vhost.

Michael Hampton
  • 244,070
  • 43
  • 506
  • 972
  • I was not aware of the try_files directive in Nginx, and using the line you provided I was able to get everything working again. – andrewvnice Feb 08 '14 at 04:29
  • Using the Puppet module I linked to in my question, this is what it looks like in the manifest. `try_files => [ '$uri $uri/ /index.php' ]` – andrewvnice Feb 08 '14 at 04:30