Just to answer myself...

Those 2 location blocks should be in the same server block!

Hope this could help someone else...

:)
Rui


On Sat, May 17, 2014 at 8:54 PM, ruiwang.sz <ruiwang.sz@gmail.com> wrote:
Hi Guys,

I just switch to 1.6.0 of nginx, but the behavior is the same. I also tried the 
apache proxy instructions, but rewrite just didn't work. I searched around, did
what I could, verified that I did have the required module, etc, but still didn't 
work -- it is so frustrating. 

For nginx, at least redirect works, but I don't know why there is only one server
block in use at a time. How do I solve this? Any help would be greatly appreciated.

Thanks,
Rui


On Sat, May 17, 2014 at 7:36 PM, ruiwang.sz <ruiwang.sz@gmail.com> wrote:
Hi Guys,

I did a little further investigation. I found that the order of 2 server blocks matter in my case.

If I put the /_x_accel_redirect/ block first, then the 2nd proxy server block is not effective.
If in the order I pasted in the previous message, then the _x_accel_redirect block is not effective.

But why is this? btw I'm using the 1.1.19 version of nginx that comes with ubuntu.

Could anyone give me a hint? I'll be really grateful.

Thanks,
Rui


On Fri, May 16, 2014 at 12:29 PM, ruiwang.sz <ruiwang.sz@gmail.com> wrote:
Hi All,

I have been trying to get the visualization through ucsc main working, thus I installed the nginx on our ubuntu(the one comes with update), then I configured it according to the wiki


Here is the section in my nginx.conf

        include /etc/nginx/conf.d/*.conf;
        #include /etc/nginx/sites-enabled/*;

        upstream galaxy_app {
        server localhost:20020;
        }
        server {
            client_max_body_size 10G;
            # ... other server stuff ...
            location / {
               proxy_pass   http://galaxy_app;
               proxy_set_header   X-Forwarded-Host $host;
               proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
           }
       }
       server {
            location /_x_accel_redirect/ {
                internal;
                alias /;
            }
        }

A couple notes:

1. I commented out 

     #include /etc/nginx/sites-enabled/*;

    should I?

2. I have two sections of 'server', I am not sure if this is correct, but the wiki does not talk about it.

I also have the following in universe_wsgi.ini:

nginx_x_accel_redirect_base = /_x_accel_redirect

Now, if I go to http://127.0.0.1, it will redirect to http://127.0.0.1:20020, our galaxy instance, which is right.
However, when i choose 'display in UCSC main' on a bigwig file, it failed to show and here is the log:

75.142.102.9 - - [16/May/2014:09:18:20 -0700] "GET /display_application/360b40e91c77a7e9/ucsc_bigwig/main HTTP/1.0" 302 - "http://128.125.28.215/root" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.137 Safari/537.36"
128.114.119.135 - - [16/May/2014:09:18:20 -0700] "GET /display_application/360b40e91c77a7e9/ucsc_bigwig/main/6e1547da5bd290c9/param/track HTTP/1.0" 200 201 "-" "genome.ucsc.edu/net.c"
128.114.119.135 - - [16/May/2014:09:18:20 -0700] "HEAD /display_application/360b40e91c77a7e9/ucsc_bigwig/main/6e1547da5bd290c9/data/galaxy_360b40e91c77a7e9.bigwig HTTP/1.0" 200 92543742 "-" "genome.ucsc.edu/net.c"
128.114.119.135 - - [16/May/2014:09:18:20 -0700] "HEAD /_x_accel_redirect/home/bioinfoadmin/app/galaxy-dist/database/files/003/dataset_3353.dat HTTP/1.0" 404 - "-" "genome.ucsc.edu/net.c"
128.114.119.135 - - [16/May/2014:09:18:20 -0700] "HEAD /galaxy/display_application/360b40e91c77a7e9/ucsc_bigwig/main/6e1547da5bd290c9/data/galaxy_360b40e91c77a7e9.bigwig HTTP/1.0" 404 - "-" "genome.ucsc.edu/net.c"

I don't know how this works -- the dataset I clicked is in fact:

/home/bioinfoadmin/app/galaxy-dist/database/files/003/dataset_3353.dat

and it is on disk. However, it gave 404:

128.114.119.135 - - [16/May/2014:09:18:20 -0700] "HEAD /_x_accel_redirect/home/bioinfoadmin/app/galaxy-dist/database/files/003/dataset_3353.dat HTTP/1.0" 404 - "-" "genome.ucsc.edu/net.c"

seems '_x_accel_redirect' is not substituted by the redirect alias '/'? but why?

I checked the permission and it is 775 for all the dir on path, and 664 for dataset_3353.dat

so www-data user has the read access.

Also, where is this dir and file?

/display_application/360b40e91c77a7e9/ucsc_bigwig/main/6e1547da5bd290c9/data/galaxy_360b40e91c77a7e9.bigwig

I don't see them anywhere on the disk at all!

I'm very confused about this. Could anyone give me a hand? I'll really appreciate!

Thanks,
Rui