LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   apache related problem (HTTP Error 403 - Forbidden ) (https://www.linuxquestions.org/questions/linux-networking-3/apache-related-problem-http-error-403-forbidden-347089/)

spandau 07-26-2005 06:37 PM

apache related problem (HTTP Error 403 - Forbidden )
 
guys i have a major problem my apache server cannot access a certain

website it tells me and my apache server : fatal error: ACCESS FORBIDDEN

if u guys have some cool ideas how can i go through with this IP BANNING

of my apache it will be greatly appreciated.

thanks in advance.

mpeg4codec 07-26-2005 07:59 PM

Make sure the directory or file you're trying to access is world readable. For instance, if your web server's root directory is /var/www, run this command:

chmod 755 /var/www

If that doesn't work, try to access the page or file again and copy the error from Apache's error.log into the forum. You can probably find that file somewhere in /var/log, or possibly /var/log/httpd.

spandau 07-26-2005 08:35 PM

Quote:

Originally posted by mpeg4codec
Make sure the directory or file you're trying to access is world readable. For instance, if your web server's root directory is /var/www, run this command:

chmod 755 /var/www

If that doesn't work, try to access the page or file again and copy the error from Apache's error.log into the forum. You can probably find that file somewhere in /var/log, or possibly /var/log/httpd.


hi man, i just looked over /var/log/httpd, but i didnt found the error that my apache server made...

i really have to access that specific site using my apache server for my phpscript to work...

its just that the current ipaddress my server is using is totally blocked out / banned out.......

Matir 07-26-2005 10:13 PM

If you are using a PHP script to access a page on another server, and THAT server is returning HTTP 403, then you're banned, whether or not you like it. Only the administrator of that site can change that. That's why we call it access control.

spandau 07-26-2005 10:17 PM

Quote:

Originally posted by Matir
If you are using a PHP script to access a page on another server, and THAT server is returning HTTP 403, then you're banned, whether or not you like it. Only the administrator of that site can change that. That's why we call it access control.

can apache server use public proxy server ip addresses instead of the banned ip address?

Matir 07-26-2005 10:30 PM

This has nothing to do with your apache server. It has everything to do with your script. What is your PHP script attempting to do?

spandau 07-26-2005 11:02 PM

Quote:

Originally posted by Matir
This has nothing to do with your apache server. It has everything to do with your script. What is your PHP script attempting to do?
hi thanks for your time... here is a piece of my script...




$mainUrl ="http://domainname/webpage.htm";
$mainHtml = '';
$mainHtml = file_get_contents($mainUrl);


i tried using a proxy ip address on my browser and i can get through inside the website, but when i tried running this script

its still not working.

Matir 07-26-2005 11:33 PM

You'd need to code a proxy wrapper into your application. There are a few examples on the php website, just search for 'proxy'.

spandau 07-26-2005 11:39 PM

Quote:

Originally posted by Matir
You'd need to code a proxy wrapper into your application. There are a few examples on the php website, just search for 'proxy'.
thanks matir....

can i ask what php site exactly is it?

can u give the url

thanks a lot!:D

Matir 07-26-2005 11:57 PM

http://www.php.net

spandau 07-27-2005 12:01 AM

Quote:

Originally posted by Matir
You'd need to code a proxy wrapper into your application. There are a few examples on the php website, just search for 'proxy'.


another followup question matir...:p

what exactly do you mean by a 'proxy wrapper' is it a php function wherein i can include and attach to my script in order to

use a certain proxy ip address, and run just like how successful my browser is using that proxy ip address.


thanks.

Matir 07-27-2005 12:10 AM

Basically, you need to open a channel to the proxy server, and connect through that channel to complete your request.

This is more than just a couple of lines of code to accomplish, and requires a fairly decent working understanding of proxy servers.

If you happen to be using PHP 5.0 or later, you can use the PEAR::Cache module to accomplish your goal, as described here:
http://bugs.php.net/bug.php?id=6701

spandau 07-27-2005 12:18 AM

Quote:

Originally posted by Matir
Basically, you need to open a channel to the proxy server, and connect through that channel to complete your request.

This is more than just a couple of lines of code to accomplish, and requires a fairly decent working understanding of proxy servers.

If you happen to be using PHP 5.0 or later, you can use the PEAR::Cache module to accomplish your goal, as described here:
http://bugs.php.net/bug.php?id=6701


thanks... i saw an example that uses the same function file_get_contents()

the example:

<?php
$context = stream_context_create(
array('http'=>
array('proxy'=>'tcp://proxy.example.com:5100')
));

$contents = file_get_contents('http://www.somesite.com/pat/to/file',
false, $context);


?>



array('proxy'=>'tcp://proxy.example.com:5100') is where i will input my public proxy ip address say...


array('proxy'=>'tcp://203.215.76.36:3128')


wherein (203.215.76.36 is a public proxy ip and 3128 is the port for it.)


am i on the right track on this one?

thanks again :cry:

Matir 07-27-2005 12:25 AM

You seem to be.

spandau 07-27-2005 12:39 AM

Quote:

Originally posted by Matir
You seem to be.

sorry if im taking much of your time matir.... but i just implemented the piece of code... and i had an error but its a different one

its not access forbidden error..

the new error is : failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request


my code is somewhat like this:


$context = stream_context_create(
array('http'=>
//array('proxy'=>'tcp://proxy.example.com:5100')
array('proxy'=>'tcp://203.215.76.36:3128')
));

$contents = file_get_contents("http://domain.com/webpage.htm", true ,$context);


i hope you can help me figure out where does the problem arises.

thank you so much....

Matir 07-27-2005 12:44 AM

Well, it could be that port 3128 is a squid proxy, whereas port 5100 is usually used by SOCKS proxies.

spandau 07-27-2005 01:06 AM

Quote:

Originally posted by Matir
Well, it could be that port 3128 is a squid proxy, whereas port 5100 is usually used by SOCKS proxies.

hello there matir i think its already midnight over there... its taking me quite awhile until my script to be done...

is it ok if you visit my thread after you wake up? ill still post some issues regarding this matter when it gets done.

thank you very much for the help i extremely appreciate it... and more power to you....:p

spandau 07-27-2005 01:21 AM

Quote:

Originally posted by Matir
Well, it could be that port 3128 is a squid proxy, whereas port 5100 is usually used by SOCKS proxies.

sorry about this martir,,,,

because i got a new error:

failed to open stream: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

my script is:



$context = stream_context_create(array('http'=>array('proxy'=>'tcp://203.167.109.146:5100')));

$contents = file_get_contents("http://domainname/webpage.htm", false ,$context);

Matir 07-27-2005 08:42 AM

Just changing the port to 5100 won't work unless there's a Socks 4/5 proxy server on that host.

spandau 07-27-2005 06:25 PM

Quote:

Originally posted by Matir
Just changing the port to 5100 won't work unless there's a Socks 4/5 proxy server on that host.

hi there again matir;)

i saw some free socks proxy sites would this work? even if the port is not exactly 5100?

the sites are:

http://www.atomintersoft.com/product...y/socks5-list/

http://www.samair.ru/proxy/socks.htm


thanks:)

Matir 07-27-2005 07:46 PM

You just need to make sure its pointed to a valid proxy.

spandau 07-27-2005 08:15 PM

Quote:

Originally posted by Matir
You just need to make sure its pointed to a valid proxy.
ive tried several socks proxies listed but i keep on getting this warning:

Warning: file_get_contents(http://www.yahoo.com) [function.file-get-contents]: failed to open stream: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond


my code is:

<?

$context = stream_context_create(array('http'=>array('proxy'=>'80.108.112.111:32167')));

$contents = file_get_contents("http://www.yahoo.com", false ,$context);


?>

socks4/5 i tried were:

201.235.78.20:1080 socks 4/5 Argentina
200.114.224.112:1080 socks 4/5 Argentina
200.126.186.153:1080 socks 4/5 Argentina
84.112.18.48:1080 socks 4/5 Austria
80.108.4.231:1080 socks 4/5 Austria
80.108.28.208:1027 socks 4/5 Austria
80.108.112.111:32167 socks 4/5 Austria


i tried them all, but all of them went in vain.... :(

Matir 07-27-2005 08:51 PM

hrrm. have you tried any http proxies?

And what version of PHP are you running?

spandau 07-27-2005 09:00 PM

Quote:

Originally posted by Matir
hrrm. have you tried any http proxies?

And what version of PHP are you running?


i have PHP 5 here......


i tried using http proxies my code is:


<?


$context = stream_context_create(array('http'=>array('proxy'=>'http://82.229.128.171:8080')));

$contents = file_get_contents("http://www.yahoo.com", false ,$context);




?>


i got a warning that says:


Warning: file_get_contents(http://www.yahoo.com) [function.file-get-contents]: failed to open stream: Unable to find the socket transport "http" - did you forget to enable it when you configured PHP?

Matir 07-27-2005 09:02 PM

Try removing the http:// from the front of the proxy name.

spandau 07-27-2005 09:05 PM

Quote:

Originally posted by Matir
Try removing the http:// from the front of the proxy name.


i did that my code now is:


<?


$context = stream_context_create(array('http'=>array('proxy'=>'82.229.128.171:8080')));

$contents = file_get_contents("http://www.yahoo.com", false ,$context);




?>


warning says:

Warning: file_get_contents(http://www.yahoo.com) [function.file-get-contents]: failed to open stream: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

Matir 07-27-2005 09:15 PM

Try taking a look at the information on this page: http://livedocs.php.mirrors.powertri.../wrappers.html

spandau 07-27-2005 09:43 PM

Quote:

Originally posted by Matir
Try taking a look at the information on this page: http://livedocs.php.mirrors.powertri.../wrappers.html
ummm... im sorry matir but im a little bit lost here regarding php wrappers...............

i dont know where in the document would i find my answer............help:confused:

kaverong 09-01-2005 12:39 AM

Hi Guys,

I also get a
403 Forbidden error ... Port 443
only when I use https

I'm running a virtual host and I use SELinux, the same problem would not be encountered whenever i disable SELinux.

my document root is /www/html wherein /www is a mounted disk partition.

i get this error in my log/messages

...audiit(1125570534.322:0): avc: denied { getattr } for pid=26442 comm=httpd path=/www dev=hda8 ino=2 scontext=root:system_r:httpd_t tcontext=system_u:object_r:file_t tclass=dir



please help

win32sux 09-01-2005 06:06 PM

Quote:

Forbidden Errors (SELinux)

You may experience a "forbidden error" when attempting to access a users public web site (http://localhost/~alice), this is generally because the permissions are either set incorrectly, or SELinux is set to "Enforcing" mode which blocks the standard suexec call needed by the Apache server. Common error is the "/home/username" permissions.

To temporarily disable SELinux so you can test the access permissions, type "setenforce 0" at the command prompt. Typing "setenforce 1" sets SELinux back to Enforcing mode.

Use the following commands to permanently adjust the SELinux file security context so Apache can access user's public web sites.

Code:

### SELinux ONLY - Enable User Website
[bash]# setsebool -P httpd_enable_homedirs true
[bash]# chcon -v -R -h -u user_u -t httpd_user_content_t /home/*/public_html

### SELinux ONLY - Disable User Website
[bash]# setsebool -P httpd_enable_homedirs false
[bash]# chcon -v -R -h -u user_u -t user_home_t /home/*/public_html


http://www.brennan.id.au/13-Apache_W...ver.html#users

just my :twocents:...



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