M
M
Max2019-01-10 00:25:34
Apache HTTP Server
Max, 2019-01-10 00:25:34

Apache 403 with Alias ​​from external folder, how to fix?

Prompt with Apache.
PrescribedAliasMatch

AliasMatch "^/wp-content/uploads/2019/../(..)(.*)$" "/mnt/hdd/dbimg/$1/$1$2"

when requesting an image at
/wp-content/uploads/2019/01/0003872d0a1895044c64db87582c6dcc.jpg

image should be taken from here
/mnt/hdd/dbimg/00/0003872d0a1895044c64db87582c6dcc.jpg

It seems that everything is correct with the regular expression, don't let 2019/01 confuse you (there can be any number instead of 01), and the folder with the final file is called by the first 2 characters of the file name.
Gives 403 error.
Read here ( https://stackoverflow.com/questions/11215283/alias...) and here ( httpd.apache.org/docs/2.4/upgrading.html ) added:
<Location "/mnt/hdd/dbimg/00">
    SetHandler dbimg
    Require all granted
  </Location>

But it still doesn't work, maybe there's a bug here. Tried different variations...
<Directory "/mnt/hdd/dbimg/00">
    Require all granted
  </Directory>

The /dbimg folder itself and everything below have the rights for admin (directoryroot user).

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Max, 2019-01-10
@wtfowned

PS
Found the keyphrase here https://stackoverflow.com/a/13355590/2103823
I had root rights on /mnt, created a test directory /tmp2 and gave it admin rights, everything worked.
Are there other ways, without changing permissions for /mnt (this is the directory where hdds are mounted) to complete the task?

S
Stalker_RED, 2019-01-10
@Stalker_RED

<Location "/mnt/hdd/dbimg/00">...
Read about what document_root is and about relative paths. Why do you need to expose your entire file system to the Internet?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question