I'm trying to setup endpoints that have .json at the end of the url
ie. mydomain.com/node/2.json

is there something in barracuda's nginx config that would prevent that?
i keep getting 404's

the only thing i found so far was a rule to make .json requests boost compatible that looks like this

###
### Make json compatible with boost caching.   
###
location ~* \.json$ {
  if ( $request_method = POST ) {
    return 405;
  }
  if ( $cache_uid ) {
    return 405;  
  }
  error_page  405 = @uncached;
  access_log  off;
  tcp_nodelay off;
  expires     max; ### if using aggregator
  add_header  X-Header "Boost Citrus 2.3";
  try_files   /cache/$device/$host${uri}_.json $uri =404;
}

any tips are greatly appreciated!

Comments

omega8cc’s picture

Status: Active » Fixed

You need to add your own location, as explained in the how-to: http://drupalcode.org/project/barracuda.git/blob/HEAD:/docs/HINTS.txt#l16

It is now supported both in the Master and Satellite instances, just the path to the custom include is different. In Octopus it is: http://drupalcode.org/project/barracuda.git/blob/HEAD:/aegir/conf/nginx_... while in Barracuda it is include /var/aegir/config/server_master/nginx/post.d/nginx_vhost_include*;.

Your custom location should probably look like below:

###
### My custom location.   
###
location ~* /node/.*\.json$ {
  try_files $uri @cache;
}

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

omega8cc’s picture

Project: Barracuda » Octopus
Component: Miscellaneous » Code
Category: support » feature
Status: Closed (fixed) » Needs work

We should support this out of the box, so non-static requests ending with .json will be sent to @drupal location instead of generate =404.

omega8cc’s picture

Status: Needs work » Fixed
7wonders’s picture

#4 confirmed as working :)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

webmasterkai’s picture

Status: Closed (fixed) » Needs work

Doesn't this prevent serving static json files even if they are in the sites/[domain]/files directory? It also skips the fast 404 if the static json file isn't found in the sites/[domain]/files directory.

omega8cc’s picture

Status: Needs work » Closed (fixed)

1. No, it doesn't break anything for any existing static files, because still $uri is checked first.
2. Yes, it no longer gives fast 404 for non-existing .json files, but that is the price here.

Also, if you have a problem with this and you think you have a better solution, please open a new issue and reference this one, because this one is fixed.

webmasterkai’s picture

Thanks for the quick response. I must be misunderstanding something. I don't seem to be able to request static .json files that exists on the server. Are .json files not allowed?

omega8cc’s picture

@webmasterkai - If you have any problem with .json files/requests, try to debug it first (because it should just work) and then feel free to open a new issue. Thanks.

omega8cc’s picture

Category: feature » bug
Status: Closed (fixed) » Needs work

Hmm, after looking at this again, I think we have a problem, indeed. Sorry for too fast and wrong response :/

This:

  if ( $cache_uid ) {
    return 405;
  }

will skip the check for static files existence for all logged in users, because it sends the requests to @drupal location directly. That is why static .json files may work only for not logged in visitors.

webmasterkai’s picture

Category: bug » feature

Thanks for the quick reply again. I was just about to open a new issue. :-)

I can confirm that the following example works for anonymous users but not authenticated users:
http://json.o4892985044.v94d.dal.host8.biz/sites/json.o4892985044.v94d.d...

Example of a static text file that works for both authenticated and anonymous:
http://json.o4892985044.v94d.dal.host8.biz/sites/json.o4892985044.v94d.d...

omega8cc’s picture

Status: Needs work » Fixed

It was a bit tricky, but is now fixed in HEAD:

http://drupalcode.org/project/octopus.git/commit/90f119b
http://drupalcode.org/project/octopus.git/commit/5ad4119

All patches have been applied and tested on your instance, so we know it works.

Thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.