Page 1 of 4 123 ... LastLast
Results 1 to 10 of 31

Thread: Apache 403 forbidden

  1. #1
    Join Date
    Oct 2011
    Beans
    29

    Apache 403 forbidden

    Good day all
    I've been puzzling over this issue for several days now, and while I've found many solutions online (including these forums) none of those have worked for me yet.

    The issue is, I have a few sites in folders below /var/www
    The one main site in particular runs off a MySQL database, with rewritten URLs. The CSS and most of the images / graphics are not loading. The only images that are loaded are those that are from files manipulated by a script, and displayed as thumbnails.

    I have my log level set to debug, but see no errors in either the access.log or error.log files. If I view the page source, and then follow a link to e.g. one of the CSS files, I get a 403 forbidden error.

    The directories are owned by www-data, and this is the user / group apache is running under.
    I am able to access the files in question via SMB. Sever name has been set, as well as setting allowoveride, not allowing multiviews (although I've tried this both ways). As an experiment, with the same issues, I copied all directories to the /home/sername/www and had the same results.

    My first venture into a headless server, so while learning a ton, I guess I've missed something too. I am doing everything via SSH.
    Any suggestions would be greatly appreciated!!

  2. #2
    Join Date
    Jul 2011
    Location
    South-Africa
    Beans
    678
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Apache 403 forbidden

    Hay,

    One thing I have found with designing and hosting my own website was that you actually need to make images "executable" to be able to display properly. There is a different term used by web developers but essentially it is the exc flag that needs to be set (for everyone).

    Try that and see if that solves your issue.

    EDIT:
    Folders, not files. See here for my thread on a similar issue:
    http://ubuntuforums.org/showthread.p...8#post12584098

    oh, that's a good point, you need to have execute permission on directories to be able to access their contents. You shouldn't need execute permission on the images though.

    (permissions on directories are slightly different from the ones used on files, the "execute" is often called "search permission" as it's required to access the inode information of files and subdirectories. For example read permission allows you to list a directory's contents, but to cd into it or access the files using many tools you also need the execute bit to be set. And it also needs to be set for all the parent directories as well...)
    Last edited by zero2xiii; August 14th, 2013 at 07:48 PM.
    Switched away from windows XP to Ubuntu 9.04. Never turned around to look back.

  3. #3
    Join Date
    May 2006
    Location
    Marseille, France
    Beans
    4
    Distro
    Xubuntu 7.04 Feisty Fawn

    Re: Apache 403 forbidden

    My guess is a permission problem.
    If you've already checked the owner of the files then take a look at their rights.

    To be sure of the problem you can also change the log verbosity for apache : http://httpd.apache.org/docs/2.2/en/logs.html
    You could then look at /var/log/apache and see what exactly is going wrong.

  4. #4
    Join Date
    Oct 2011
    Beans
    29

    Re: Apache 403 forbidden

    Thank you both for the replies. I have read through the links too, to be sure.
    I do believe it is a permissions issue, but to trace it seems to be the issue.

    To the best I can see, www-data owns the /var/www directory, and all those inside.
    Permissions on all files are set to 775, also to the best of my knowledge.
    Files have Owner RWE, Goups has RWE and public has RE

    No CSS, direct image loads, or direct photo loads (as in not shown in an altered state by my thumbnail scripts) are showing.

    I have the Apache log level set to debug, but have not seen any errors in the error or access logs.
    About all I'm seeing is a few zlib items and their compression levels.

    The only way to see the 403 is to view the source, and then click on the css reference in the source.

  5. #5
    Join Date
    Feb 2008
    Beans
    Hidden!

    Re: Apache 403 forbidden

    DorkBlog

    If you want something you've never had, then you must do things you've never done.
    Tools every shell scripter should have, explainshell, shellcheck, and crontab sandbox.

  6. #6
    Join Date
    Oct 2011
    Beans
    29

    Re: Apache 403 forbidden

    @Habitual

    Thank you for the link (and syntax correction, noted!!)
    To the best of what I can see, everything from that link is in order. And have set my apache2.conf log level to debug as well as in the site config, and no errors in there at all.

    All file and directory permissions seem in place.
    Directories are owned by www-data (which apache runs under) with drwxrwxr-x
    And files are all owned by www-data with rwxrwxr-x

    Altering the AllowOverride to match those in the link did cause a 500 error. Leaving it as 'AllowOverride all' continues to work as before.

    Still no CSS or other files loading though.

  7. #7
    Join Date
    Feb 2008
    Beans
    Hidden!

    Re: Apache 403 forbidden

    Quote Originally Posted by andrewgerm View Post
    Good day all
    I've been puzzling over this issue for several days now, and while I've found many solutions online (including these forums) none of those have worked for me yet.

    The issue is, I have a few sites in folders below /var/www
    The one main site in particular runs off a MySQL database, with rewritten URLs. The CSS and most of the images / graphics are not loading. The only images that are loaded are those that are from files manipulated by a script, and displayed as thumbnails.

    I have my log level set to debug, but see no errors in either the access.log or error.log files. If I view the page source, and then follow a link to e.g. one of the CSS files, I get a 403 forbidden error.

    The directories are owned by www-data, and this is the user / group apache is running under.
    I am able to access the files in question via SMB. Sever name has been set, as well as setting allowoveride, not allowing multiviews (although I've tried this both ways). As an experiment, with the same issues, I copied all directories to the /home/sername/www and had the same results.

    My first venture into a headless server, so while learning a ton, I guess I've missed something too. I am doing everything via SSH.
    Any suggestions would be greatly appreciated!!
    andrewgerm:

    No worries.
    Generally speaking it is good practice to use
    755 for directories and
    644 for files.

    does the apache error log(s) file show any 503 errors?

    Code:
    zgrep 503 /var/log/apache/*
    should show them.

    you said
    Quote Originally Posted by andrewgerm
    The directories are owned by www-data
    but are the files below them owned by www-data as well?
    and
    Quote Originally Posted by andrewgerm
    The one main site in particular runs off a MySQL database, with rewritten URLs. The CSS and most of the images / graphics are not loading
    is this a wordpress site?
    DorkBlog

    If you want something you've never had, then you must do things you've never done.
    Tools every shell scripter should have, explainshell, shellcheck, and crontab sandbox.

  8. #8
    Join Date
    Oct 2011
    Beans
    29

    Re: Apache 403 forbidden

    @Habitual
    A big thank you, once again.

    I tried you command to find the 403 errors (I tried both ways, but guess it should be 403 and not 503?)
    Nothing on either 403 or 503, although some old entries from way back, I did browse the site just prior to running the command, as I had changed the log reporting level from warn to debug this week (these errors are from last week).

    Code:
    tail -f /var/log/apache2/error.log
    This gives entries showing that the various JS and CSS files are being deflated by mod-deflate.

    As mentioned though, if I view the site code, and click on a link to a CSS file, this is when the 403 is displayed.

    This site will have WordPress integrated, but currently it is the propriety code (excluding WordPress, etc.) that is accessing the MySQL.

    Both directories and files are owned by www-data. My username (not running as root) is in the www-data group as well.

    Still puzzling over things. A big thank you again

  9. #9
    Join Date
    Feb 2008
    Beans
    Hidden!

    Re: Apache 403 forbidden

    Quote Originally Posted by andrewgerm View Post
    if I view the site code, and click on a link to a CSS file, this is when the 403 is displayed.
    andrewgerm:

    Can you clarify the above snippet? It sounds like the site displays fine, but some CSS element when viewed as "site code" contains a reference
    to a resource that is giving you the 403?

    something like right-mouse click (on my own site) > "View Page Source" in Firefox...shows me...?
    Code:
    <script type="text/javascript">
    //<=!=[=C=D=A=T=A=[
    try{if (!window.CloudFlare) { var CloudFlare=[{verbose:0,p:0,byc:0,owlid:"cf",mirage:{responsive:0,lazy:0},mirage2:0,oracle:0,paths:{cloudflare:"/cdn-cgi/nexp/abv=833003145/"},atok:"440f09720223f72397ee1138ab381fa1",zone:"bournetoraiseshell.com",rocket:"a",apps:{}}];document.write('<script type="text/javascript" src="//ajax.cloudflare.com/cdn-cgi/nexp/abv=340409193/cloudflare.min.js"><'+'\/script>')}}catch(e){};
    //]=]=>
    </script>
    <link rel="canonical" href="http://www.bournetoraiseshell.com/">
    <link rel="search" href="http://www.bournetoraiseshell.com/search.php" title="Advanced Search">
    <link rel="stylesheet" type="text/css" href="http://www.bournetoraiseshell.com/layout/professional/style.css">
    and I this were your "site code" and clicked something similar to
    http://www.bournetoraiseshell.com/la...onal/style.css
    you get a 403?

    Good catch on the [45]03 error detail.

    output of these 2 commands please?
    Code:
    ls -ld /var/www/*
    find `pwd` /var/www/ -name .htaccess
    Suggestion: Quit messing with user group permissions at this time
    YOU don't "need" to be in any additional groups to isolate and troubleshoot this permissions error.
    Last edited by Habitual; August 16th, 2013 at 02:05 AM.
    DorkBlog

    If you want something you've never had, then you must do things you've never done.
    Tools every shell scripter should have, explainshell, shellcheck, and crontab sandbox.

  10. #10
    Join Date
    Oct 2011
    Beans
    29

    Re: Apache 403 forbidden

    @habitual

    Thank you again for the reply.

    Apologies. I'll try clarify what I meant about the CSS. If I load the site over the local network, the pages are showing, and grabbing the relevant data from MySQL. The site colours, formatting and images (those of the menu, logo, etc.) are not showing. Only images that are generated on-the-fly via a script are showing up. I am using Chromium, so right clicking and selecting view source displays the page code. From the source view, I can click on the links to the CSS files, and that is when I am seeing the 403 Forbidden error.

    Following your link to the CSS file, is what I would expect to see, yes. I have my CSS and JS laid out for easy reading when developing, but once ready to publish, I min them.

    Out put from the commands:
    ls -ld /var/www/*
    Code:
    -rwxrwxr-x  1 www-data www-data   22 Jul 30 18:21 /var/www/info.phpdrwxrwxr-x 18 www-data www-data 4096 Jul 30 18:23 /var/www/samdb
    drwxrwxr-x  3 www-data www-data 4096 Jul 30 18:24 /var/www/samdb-admin
    drwxrwxr-x  6 www-data www-data 4096 Jul 30 18:24 /var/www/samdb-emailed
    drwxrwxr-x  2 www-data www-data 4096 Jul 30 18:24 /var/www/test
    drwxrwxr-x  3 www-data www-data 4096 Jul 30 18:24 /var/www/videolist
    find 'pwd' /var/www/ -name .htaccess
    /var/www/samdb/.htaccess
    [/CODE]



    The site in question is the /var/www/samdb site. Others are just code portions, testing, etc.

    And staying away from user-groups

    The index is specified in the .htaccess. This entire site worked correctly prior, but with a massive server failure on my development server, I have had to restore everything to a new machine.

    Apache enabled site conf, for reference:
    Code:
    <VirtualHost *:80>
    	ServerAdmin webmaster@localhost
    	ServerName SAMDB-Dev
    
    
    	DocumentRoot /var/www
    	<Directory />
    		Options FollowSymLinks
    		AllowOverride None
    	</Directory>
    	<Directory /var/www/>
    		Options Indexes FollowSymLinks
    		AllowOverride all
    		Order allow,deny
    		allow from all
    	</Directory>
    
    
    	ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    	<Directory "/usr/lib/cgi-bin">
    		AllowOverride None
    		Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    		Order allow,deny
    		Allow from all
    	</Directory>
    
    
    	ErrorLog ${APACHE_LOG_DIR}/error.log
    
    
    	# Possible values include: debug, info, notice, warn, error, crit,
    	# alert, emerg.
    	LogLevel debug
    
    
    	CustomLog ${APACHE_LOG_DIR}/access.log combined
    
    
    	Alias /doc/ "/usr/share/doc/"
    	<Directory "/usr/share/doc/">
    		Options Indexes MultiViews FollowSymLinks
    		AllowOverride None
    		Order deny,allow
    		Allow from all
    	</Directory>
    
    
    </VirtualHost>

    The info.php file contains only the phpinfo(); function, and loads. When loading the default address for the server over the network, I see the directory listing of folders, and can successfully navigate each. Mod-rewrite is also working as it should.

    A huge thank you, once again. I'm glad to see I'm only one of many having this issue, but unfortunately none of the current proposed solutions has worked (else I'm missing something that's probably obvious). First foray into a headless server

Page 1 of 4 123 ... LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •