LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-12-2017, 01:35 PM   #1
tonj
Member
 
Registered: Sep 2008
Posts: 523

Rep: Reputation: 37
apache symlink gives ERROR 403: Forbidden


I'm running centos 6 server and I have a network drive mounted as /media/disc2. I've created a symlink in my website (on the same server) that points to /media/disc2 and I want to download stuff from it via wget on another machine. But I get ERROR 403: Forbidden
I can access folders via the symlink but i can get files. The files are on a drive connected to a linksys nslu2 network storage device I can't change the permissions on the network drive files from the centos 6 server, the linksys won't allow it. The files on /media/disc2 show up as user 501 and group 502 but apache can't work with this. Is there any way to get this symlink properly working?
 
Old 03-13-2017, 02:21 AM   #2
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 17,401
Blog Entries: 10

Rep: Reputation: 5212Reputation: 5212Reputation: 5212Reputation: 5212Reputation: 5212Reputation: 5212Reputation: 5212Reputation: 5212Reputation: 5212Reputation: 5212Reputation: 5212
maybe apache is set up to disallow direct access to files.
this is usually remedied through a local .htaccess with something like this:
Code:
Order Deny,Allow
Allow from all
Options +Indexes
 
Old 03-13-2017, 03:29 AM   #3
tonj
Member
 
Registered: Sep 2008
Posts: 523

Original Poster
Rep: Reputation: 37
thanks for your response ondoho, I tried what you said but it didn't work. I created a local .htaccess file containing what you gave but When trying to wget a file I'm still getting ERROR 403: Forbidden
 
Old 03-13-2017, 03:46 AM   #4
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 5,655
Blog Entries: 3

Rep: Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901
Try removing .htaccess if you have direct control over Apache's real configuration files. The .htaccess files are redundant and messy if you have direct access to the configuration.

Then in the configuration file for the appropriate Directory or Location stanza, try adding +FollowSymLinks or +SymLinksIfOwnerMatch in the relevant Options directive.
 
Old 03-13-2017, 05:14 AM   #5
tonj
Member
 
Registered: Sep 2008
Posts: 523

Original Poster
Rep: Reputation: 37
thanks turbocapitalist I tried +FollowSymLinks and +SymLinksIfOwnerMatch in httpd.conf and restarted apache but the symlink still doesn't work
 
Old 03-13-2017, 05:16 AM   #6
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 5,655
Blog Entries: 3

Rep: Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901
What are the file permissions of the symlink's target? Can the user that Apache is running both look up the directory and read the actual file?
 
Old 03-14-2017, 04:03 AM   #7
tonj
Member
 
Registered: Sep 2008
Posts: 523

Original Poster
Rep: Reputation: 37
the target of the symlink is the folder /media/disc2/vps-backups, disc2 is a usb drive connected to a linksys nslu2 on the network. The permissions of /media/disc2/vps-backups are:
Quote:
# ls -ld /media/disc2/vps-backups
drwxrwxr-x 3 502 501 0 Mar 13 09:04 /media/disc2/vps-backups
the files in the target folder are what's giving me the trouble- eg there's a file in this folder called text-files.zip.
Quote:
ls -ld /media/disc2/vps-backups/text-files.zip
-rwxrwx--x 1 502 501 4877 Mar 11 10:30 /media/disc2/vps-backups/text-files.zip
In midnight commander the permissions of text-files.zip appear as:
Quote:
permissions 100771
owner name: 502
group name 501.
The permissions can't be altered because they're controlled by the external linksys nslu2 device that takes the drive containing text-files.zip.
I log into the sever as root so I hope that answers your question about the user that Apache is running. If it's not possible to get apache to access these files I'll have to plug a usb drive into the server itself and symlink to that, and thanks for your further help btw.

Last edited by tonj; 03-14-2017 at 04:09 AM.
 
Old 03-14-2017, 04:20 AM   #8
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 5,655
Blog Entries: 3

Rep: Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901
There's no way for Apache to read that file. The permisssions for Other are the problem:
-rwxrwx--x 1 502 501 4877 Mar 11 10:30 /media/disc2/vps-backups/text-files.zip

The usual way would be to have Read permissions for Other. So it should be like this:
-rwxrwxr-x 1 502 501 4877 Mar 11 10:30 /media/disc2/vps-backups/text-files.zip

If you cannot change regular permissions, can you use ACLs for that mount?

Also, the eXecutable bit does not need to be set for a Zip file.
 
Old 03-14-2017, 08:46 AM   #9
tonj
Member
 
Registered: Sep 2008
Posts: 523

Original Poster
Rep: Reputation: 37
ok thanks, regarding 'ACLs for that mount', I might have a chance if I knew what an acl was. I'll have to do some reading...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Apache Error(403 Forbidden) deto86 Slackware 7 12-13-2011 02:04 AM
403 - Forbidden(Apache error) amritpalpathak Linux - Software 5 04-21-2011 01:08 PM
Apache: 403 Forbidden Error daemonkl Linux - Newbie 4 10-14-2007 12:15 PM
apache error, 403 forbidden afrodocter Linux - Software 6 08-09-2004 08:35 PM
apache 403 error forbidden? bulliver Linux - General 4 01-31-2003 07:47 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:23 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration