Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
410 views
in Technique[技术] by (71.8m points)

linux - Apache 2.4.37 getting error 404 when accessing a file via Alias in directory outside of docroot

Pls help me I've spent enough hours on this with no great result..

I have the following config in my /etc/httpd/conf.d/20-myweb-443.conf :

<VirtualHost *:443>
  ServerName myserver.com

  ## Vhost docroot
  DocumentRoot /var/lib/sm

  ## Script alias directives
  ScriptAlias /sm/sm.cgi "/usr/share/sm/cgi/sm.fcgi"
  ScriptAlias /cgi-bin/ "/"


  ## Alias declarations for resources outside the DocumentRoot
  Alias /sm/files /var/lib/sm/files
  Alias /otherdata /var/lib/otherdata/files

  <Directory /var/lib/sm/files>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Require all granted
    AuthType None
  </Directory>

  <Directory /var/lib/otherdata/files>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Require all granted
    AuthType None
  </Directory>


  ## Logging
  ErrorLog /var/log/httpd/error_ssl.log
  LogLevel warn
  ServerSignature Off
  CustomLog /var/log/httpd/access_ssl.log combined


  ## SSL directives
  SSLEngine on
  SSLCertificateFile /etc/httpd/conf/ssl.crt/server.crt
  SSLCertificateKeyFile /etc/httpd/conf/ssl.key/server.key
  SSLCACertificatePath /etc/pki/tls/certs/
  SSLCACertificateFile /etc/httpd/conf/ssl.crt/ca.crt
  SSLOptions 
  <FilesMatch ".(cgi|shtml|phtml|php|txt)$">
    SSLOptions +StdEnvVars
  </FilesMatch>

I can access https://myserver.com/sm/sm.cgi just fine and the script display everything normally. When I try to access https://myserver.com/otherdata , it shows me 2 (txt) files listed in the "Index of /otherdata" (although I noticed the icons were "broken"). However, when I tried to access any of the 2 files (test.txt) by clicking on the links, it gives me a 404 The requested URL was not found on this server. The url I got was https://myserver.com/test.txt.Although the file is clearly there on the server (/var/lib/otherdata/files/test.txt) , its not able to "find" it.

The alias is working because it did redirect me to folder location /var/lib/otherdata/files and the permission on test.txt is 755, so what gives??

apachectl -S output is below :

apachectl -S
VirtualHost configuration:
*:443                  myserver.com (/etc/httpd/conf.d/20-myweb-443.conf:1)
*:80                   myserver.com (/etc/httpd/conf.d/20-myweb-80.conf:1)
ServerRoot: "/etc/httpd"
Main DocumentRoot: "/etc/httpd/htdocs"
Main ErrorLog: "/var/log/httpd/error_log"
Mutex ssl-cache: using_defaults
Mutex default: dir="/etc/httpd/run/" mechanism=default 
Mutex fcgid-pipe: using_defaults
Mutex ssl-stapling-refresh: using_defaults
Mutex fcgid-proctbl: using_defaults
Mutex ssl-stapling: using_defaults
PidFile: "/etc/httpd/run/httpd.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="apache" id=48
Group: name="apache" id=48

Appreciate if anyone can shed any light on why the files couldnt be accessed? There isnt an actual error in the logs when I got the 404 error while trying to open the file..

Thanks J


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...