0

Update! (at the end)

Here's my server directory:

/pub/
 |
 `---html/
 |   |
 |   `---_h5ai/
 |   |   |
 |   |   `---public/
 |   |       |
 |   |       `---index.php
 |   |
 |   `---<Some Other Files>
 |
 `---dl/
     |
     `---_h5ai/
     |   |
     |   `---public/
     |       |
     |       `---index.php
     |
     `---<Some Other Files>

And here's a snippet of nginx.conf:

root /pub/html;

location / {
    index  index.html index.htm index.php /_h5ai/public/index.php;
}

location /dl {
    root   /pub;
    index  index.html index.htm index.php /dl/_h5ai/public/index.php;
}

Problem:

myserver.tld/_h5ai/public/index.php
Worked without an issue;

myserver.tld/dl/_h5ai/public/index.php
Keeps showing 404;

Why don't I set the index for location /dl {} to /_h5ai/public/index.php?
It doesn't work. Please take a look at this page: https://larsjung.de/h5ai/
And when I do so, while the UI works fine,the directory listing will be empty. So yeah, the _h5ai has to be placed in the root directory of the listing -- /pub/dl in this case.

Wrapping it up:

All I need is for h5ai to work underneath myserver.tld/dl/ -- I don't really need it for root cuz that's gonna be serving regular webpages, and /dl is where I plan to host my file archive.

I'm not gonna make my directory look like /pub/html/dl/ cuz that looks nasty -- the same reason I didn't just throw my website into /var.

I thought that setting up an alternative location would also redirect php requests but apparently that's not the case :-(

All permissions are set correctly underneath /pub/, owned by www-data with reading & execution enabled for everyone.

So please take a look and I'd appreciate any help :-)


Additional Info:

OS: Ubuntu Server 14.04.1 Trusty
Nginx Version: 1.12.0
PHP Version: 5.5.9


Here's the update:


So right after I posted this question a suggested Q&A caught my attention.
alias directive with nested location to catch php files - requests for php files giving 404
And I'm pretty sure that this is the issue...so here's the PHP part of my nginx.conf:

location ~ \.php$ {
    try_files $uri =404;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
}

Configuring it this way, $document_root will be inherited from the root line (at the beginning of my nginx.conf), which is /pub/html, then of course the fastcgi gate wouldn't find /pub/html/dl/_h5ai/public/index.php -- it doesn't exist.
So after I added
root /pub;
to the php block, H5ai did work under /pub/dl -- which is nice!
--but not quite :-(
See so far I only wanted php under /pub/dl, but who knows when I also need it somewhere else...and I'm pretty sure there's a way to make it work everywhere -- so yeah, I'm gonna leave this question open until a smart guy (or girl ;-) makes it work in both /pub/html and /pub/dl :-)

  • Take a look at this Also, check your nginx logs. – user2967920 Apr 18 '17 at 7:45
  • The logs are fine...showing 404's... :-( – Samm Apr 18 '17 at 22:05

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.