According to this site:
http://httpd.apache.org/docs/2.2/howto/access.html
I need to use something like the script below to block access to my site for everyone except specific ip addresses:
Order deny,allow
Deny from all
Allow from dev.example.com
It's not clear from that site, where I type this script.
I am using Ubuntu 10.04 as my development machine.
Write exact IPs or it's starting part including ending dot under allow from and you are done.
Order deny,allow
Deny from all
Allow from 192.168.1.1
Allow from 192.168.1.2
Allow from 10.0.
BTW, belongs to ServerFault.
Related
I'm using a server 2008 r2. There I've installed Wamp on port 8080, SSRS on port 8063 and Some IIS sites on various ports.
I've installed CCproxy on the same server.
The funny thing is, I can't access them via server IP:port (192.168.8.100:8080) But I can, however, access it by Host:port (Mainserver:8080).
Then I thought it might be a clash between those services and installed wamp on a windows 8.1 computer and even that I can't access via the IP.
Please help.
Thanks
it looks like you are trying to access your website by using the local IP range 192.168.1.100. In some WAMP default configs, the devs have set the apache config to disallow access except from localhost.
Try to open the httpd.conf file located at
C:\wamp\bin\apache\apache#.#.#\conf\httpd.conf
Find the <Directory "c:/wamp/www"> block and replace the Order Deny,Allow and everything that follows with Order Allow,Deny followed by Allow from all. The end result should look like something similar to this:
DocumentRoot "c:/wamp/www"
<Directory "c:/wamp/www">
Options Indexes FollowSymLinks
Order Allow,Deny
Allow from all
</Directory>
To be safe, look into the virtual hosts config file and see if you find any Order Deny,Allow directives and replace them as well. The file is located at C:\wamp\bin\Apache#.#.#\conf\extra\httpd-vhosts.conf
You can read more about Order Directive from the Apache Documentation
I have a very simple .htaccess file:
<RequireAll>
Require all granted
# require localhost
Require ip 127.0.0.1
</RequireAll>
and it works... sometimes!
Sometimes, it will throw me a 403, and the error.log explains:
[client ::1:65443] AH01630: client denied by server configuration
Why won't it match that local client to the Require ip 127.0.0.1 rule?
As it turns out, Apache 2.4's Require matches the IP exactly. If you have multiple IP addresses aliasing localhost, you need to list all of them (or use a special alias, if one exists, as explained below).
In this particular case, the error.log entry reveals it all: The client connected through the IPv6 interface (ip == ::1). That needs to be white-listed as well:
<RequireAll>
Require all granted
# require localhost
<RequireAny>
Require ip 127.0.0.1
Require ip ::1
</RequireAny>
</RequireAll>
Any suggestions as to whether there is a simpler/safer method to get this done, are very welcome!
Update
As Helge Klein suggests, Require local is a more concise alternative:
<RequireAll>
Require all granted
# require localhost
Require local
</RequireAll>
Require ip 127.0.0.1
Require ip ::1
The Require all granted is the equivalent to:
Order allow,deny
Allow from all
from earlier Apache versions, which open the site to everyone. If your intention is to block the site to everyone, except certain IPs, you should start with a:
Require all denied
You can find more info here: Upgrading to 2.4 from 2.2
I don't use .htaccess since I have Apache installed on my workstation, and have full access to the http.conf file. But for a site like phpmyadmin where I want to limit where people log from, I have this:
Require all denied
Require ip 127.0.0.1
First line denies access to everyone, including my own workstation.
Second line adds my workstation localhost ip to the list of only allowed connections.
No RequireAll or RequireAny tags. Again in .htaccess those tags may be needed.
I was looking and can't find a way to set it so i just setup php my admin and my client put his IP Address, username, and password in so he can log-in to php my admin?
You can add a Directory directive to your phpmyadmin.conf file:
<Directory "/path/to/phpmyadmin">
Order Deny,Allow
Deny from all
Allow from 0.0.0.1
Allow from 0.0.0.2
</Directory>
where 0.0.0.1 and 0.0.0.2 are IPs you'd like to restrict access to. You probably don't want him having to type his IP address into a box as part of the user/pass flow. Much better to simply set it on your server end.
More information on locking down PHPMyAdmin can be found here: http://www.linuxbrigade.com/lock-down-your-phpmyadmin-access/
Via google analytics I noticed that there is website which is scrapping my content automatically.. His content 100% matches mine. is there any way I could block that website host from accesing my server at all? Any solutions what I could do about this?
Im running LAMP web host on CentOS.
If the IP address of the scraping host is static, you can use .htaccess to block this IP, like:
order allow,deny
deny from 111.111.111.111
allow from all
If the IP address is variable, but the user agent is constant, you can use agent blocking:
BrowserMatchNoCase SpammerRobot bad_bot
BrowserMatchNoCase SecurityHoleRobot bad_bot
Order Deny,Allow
Deny from env=bad_bot
I am trying to open my host address using my host name, but I am getting following error:
You can see the host URL above.
Can someone help me to resolve this issue?
As the error states you cannot access it outside you local network. In another words - your apache xampp is configured to accept calls only from 127.0.0.1 or localhost. For xampp this is defined in location match directive for apache look at the following topic, it covers the most common cases. Note however that this might be security issue.
http://www.apachefriends.org/f/viewtopic.php?p=185823
This will provide you more info on how allow and deny can be configured
http://httpd.apache.org/docs/2.2/mod/mod_authz_host.html#allow
Something like this should be in your httpd-xampp.conf
<LocationMatch "^/(?i:(?:xampp|licenses|phpmyadmin|webalizer|server-status|server-info))">
Order deny,allow
Deny from all
Allow from ::1 127.0.0.0/8 **your.local.ip.address**
ErrorDocument 403 /error/HTTP_XAMPP_FORBIDDEN.html.var
</LocationMatch>