X-Accel-Redirect + php not working

795 views Asked by At

Alright guys, I recently started messing with nginx and I need some help. I spent an entire day trying to figure this and I am simply done with it.

After I set the header in php for x-accel-redirect to work, I get an empty response. I am trying to serve image files from an external location to the website's root folder but in the same computer.

Can somebody point out what I'm doing wrong?

The funny/weird part is that I do not get any errors or warnings from nginx. I also do not get anything on the access/error logs, even with debug error logs turned on.

here is my nginx.conf

    user Omi Admin;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  debug;
#error_log  /usr/local/var/log/nginx/error.log  debug;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

#log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
#                  '$status $body_bytes_sent "$http_referer" '
#                  '"$http_user_agent" "$http_x_forwarded_for"';

#access_log  logs/access.log  main;

sendfile        on;
#tcp_nopush     on;

#keepalive_timeout  0;
keepalive_timeout  65;

#gzip  on;

server {
    listen       80;
    server_name  localhost;

    #charset koi8-r;

location /unprocessed {
internal;
alias /usr/local/MyMateApp/ean_images/unprocessed;  
    }

root /Users/Omi/Desktop/CustomerServiceWebsite/www;
index index.html index.htm index.php;

    error_page  404              /404.html;        

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
        try_files      $uri = 404;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}

# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
#    listen       8000;
#    listen       somename:8080;
#    server_name  somename  alias  another.alias;

#    location / {
#        root   html;
#        index  index.html index.htm;
#    }
#}


# HTTPS server
#
#server {
#    listen       443 ssl;
#    server_name  localhost;

#    ssl_certificate      cert.pem;
#    ssl_certificate_key  cert.key;

#    ssl_session_cache    shared:SSL:1m;
#    ssl_session_timeout  5m;

#    ssl_ciphers  HIGH:!aNULL:!MD5;
#    ssl_prefer_server_ciphers  on;

#    location / {
#        root   html;
#        index  index.html index.htm;
#    }
#}
include servers/*;

}

And here is where I set the header in php

header('X-Accel-Redirect: /unprocessed/' . $fileName);

I get a response back but it's simply empty.

0

There are 0 answers