ejschmitt / delayed_job_web

Resque like web interface for delayed job
MIT License
478 stars 188 forks source link

HTTP_X_ACCEL_MAPPING in NGINX breaks CSS delivery #99

Open kurttomlinson opened 6 years ago

kurttomlinson commented 6 years ago

I recently updated my NGINX configuration to allow Rails to hand off file downloads to NGINX. Unfortunately, this breaks the CSS for delayed_job_web. My NGINX configuration is below.

With my new configuration, the CSS for delayed_job_web breaks. I know this is related to https://github.com/ejschmitt/delayed_job_web#serving-static-assets, but I can't figure out how to fix it. If I comment out the "passenger_env_var HTTP_X_ACCEL_MAPPING ..." line, then the CSS in delayed_job_web works, but NGINX no longer takes control of sending files.

Is there a way to adjust the HTTP_X_ACCEL_MAPPING header so that I can use delayed_job_web and offload sending files to NGINX?

server {
    listen              7000;
    server_name         localhost;
    root                /www/pricer_pro/public;   # <--- be sure to point to 'public'!
    passenger_enabled   on;
    rack_env            development;
    # Allow NGINX to serve any file in /www/pricer_pro/__send_file
    # via a special internal-only location.
    location /__send_file_accel {
      internal;
      alias /www/pricer_pro/__send_file;
    }
    passenger_set_header X-Sendfile-Type "X-Accel-Redirect";
    passenger_env_var HTTP_X_ACCEL_MAPPING /www/pricer_pro/__send_file/=/__send_file_accel/;
    passenger_pass_header X-Accel-Redirect;
}