I think that the point of this module is to pull files from a production server in case they don't already exist on the staging server.

However, currently there are no checks to see if the file exists locally already, except if it's an imagecache generated image.

stage_file_proxy should check to see if file_exists() before polling the stage_file_proxy_origin server.

Comments

StephenBrown’s picture

Here's a patch to check in the init function. Patch done against 7.x-1.x branch.

As a side effect, this should also mitigate DOS by misconfiguration if enabled and pointed to itself.

greggles’s picture

Status: Active » Needs review

Can you give a scenario for how to trigger this?

My sense is that a properly functioning .htaccess should prevent this from happening. Maybe there's a small race situation?

  # Pass all requests not referring directly to files in the filesystem to
  # index.php. Clean URLs are handled in drupal_environment_initialize().
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !=/favicon.ico
  RewriteRule ^ index.php [L]
gngn’s picture

Issue summary: View changes

I think Stephen is right.

I got a (htaccess protected) live server with an image missing on my development server.
stage_file_proxy downloads the missing file - but not just once but 21 times!
(I don't know why 21 times - maybe some browser settings? It's the same in firefox, chrome and opera).

If I put in the patch from #1 the file is downloaded only once.

Correct me if I got something wrong.

greggles’s picture

I also stephen is right, but only in some scenarios. I just tested again and couldn't reproduce the problem as its been described.

samuel.mortenson’s picture

Status: Needs review » Needs work

I agree that this is a problem with .htaccess, could StephenBrown or gngn provide a copy of their .htaccess file so that we can replicate the issue? With a standard Drupal .htaccess file this issue does not occur.

greggles’s picture

Status: Needs work » Postponed (maintainer needs more info)

I think this is a better status if we're waiting on information.

greggles’s picture

Category: Bug report » Support request
Status: Postponed (maintainer needs more info) » Fixed

Without information, closing.

Status: Fixed » Closed (fixed)

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