Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am trying to download a file using curl from a machine running apache2. My site (000-default) configuration looks like this:

<VirtualHost *:80>
    DocumentRoot /home/user/files/
    <Directory /home/user/files/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
    </Directory>
</VirtualHost>

From another machine on the same network I do:

curl http://my-share/sample.text -o "test.txt"

I then get:

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   301  100   301    0     0   4198      0 --:--:-- --:--:-- --:--:--  4239

but if I cat the content of the file is contains:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
<p>You don't have permission to access /sample.textconfig
on this server.</p>
<hr>
<address>Apache/2.2.16 (Debian) Server at my-share Port 80</address>
</body></html>

I can ssh to the my-share debian server just fine. Why can't I access the file, is it a firewall issue?

share|improve this question

2 Answers 2

My guess would be that you're apache user (normally something like www-data) dies not have read access to the file /home/user/files/sample.text or to one of the parent directories.

Having a look at the error log of apache would help you pinpoint the issue you are facing.

share|improve this answer
    
In the log it just says: File does not exist: /var/www/sample.text . So is the solution to give the www-data user access to the /home/user/files folder somehow? –  u123 Jan 28 at 1:03
    
the path /var/www/sample.text tells me that instead of your virtualhost, the default site is being used. Try adding the "ServerName my-share" directive to force your virtualhost to be used. –  user76776 Jan 28 at 14:07
    
I have tried to copy the files to /var/www and change to read/write permissions. I can now access them in the browser e.g 'my-share/sample.text' but using curl (on the same client machine) still gives the "You don't have permission to access" xml file. So maybe its not an apache2 problem but instead a curl problem. –  u123 Jan 28 at 14:49
    
What do the logs say for the requests that you do using curl? –  user76776 Jan 28 at 15:20
In the log it just says: File does not exist: /var/www/sample.text . So is the solution to give the www-data user access to the /home/user/files folder somehow? –  u123 2 hours ago

Did I read it correctly? Apache is reading from /var/www directory and you want to serve your files from /home/user/files? You may want to recheck your Apache config if that's true.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.