How to restrict the visit to my apache server within a specified IP range?


My computer is running SUSE Linux Enterprise Server 11 (x86_64). I have set up an apache server there. The version is Apache/2.2.10 (Linux/SUSE) PHP/5.2.14 with Suhosin-Patch mod_python/3.3.1 Python/.

It works well. I can reach the server and visit the webpages from other computers. The problem is every computer can visit it. I just want to some people can reach my server by specifying the IP address, or computer name, or whatever else. Do you guy have any idea how I can do it?

Thanks for any suggestions and comments.


I guess you know this is an openSUSE forums and that any answer here is most likely to be based on openSUSE and thus not have to be applicable to your SUSE Linux Enterprise Server?

Check out this directive: mod_authz_host - Apache HTTP Server

On 06/09/2011 02:06 PM, davidehs wrote:

> My computer is running SUSE Linux Enterprise Server 11 (x86_64).
> Thanks for any suggestions and comments.

you are welcome to seek advice here, but BE ADVISED that many of the
answers might be from folks who have never run SLES (or maybe never even
heard of it before) and you are likely much better off if you seek
assistance from the Novell forums, via:

same pass/ID as used here works there…

via NNTP openSUSE 11.4 [] + KDE 4.6.0 + Thunderbird 3.1.10
Acer Aspire One D255, 1.66 GHz Atom, 1 GB RAM, Intel Pineview graphics

  • When your gecko is broken you have a reptile dysfunction! *

To help you understand this, if you put this in e.g. your .htaccess file:

  Order deny,allow
  Deny from all
  Allow from

Then only can get a look in.

Similarly “Allow from 192.168.” allows a broader range
and so on

To all the ppl who think the questioner might be better off elsewhere, this is a question about Apache servers. It would equally well be answered in the Linux Mint forums. Asking it here is just fine because it’s a Linux-wide question.

Hi, hcvv and DenverD,

Thanks for your reminding. I will ask questions about SLES at the Novell forum in the future.

Hi Swerdna,

Thanks for your encouraging and your suggestions.

Actually, I use both openSUSE and SLES. I have openSUSE on my laptop and run the SLES on the server machine. But I am pretty new with SUSE, and even with linux. I just transferred from a windows system to linux two months ago.

Now continue my question.
I could not find the .htaccess file on my computer. So I made one at /srv/www/htdocs/.htaccess, and added the following two lines,
Order deny,allow
Deny from all
into it.

Then, I stopped and restarted the apache. But my laptop still can access the web pages.
My laptop and the server machine are both located under the domain of my university. Is this the reason why the access can not be blocked?



It is not that we ill discourage you to ask here, but we only want you to know which sort of experst are mainly here. It is up to you to decide where you ask.

In this case, as Swerdna pointed out, it is a pure Apache2 question and as such operating system independent.

That said, when you run Apache you should know something about how it canve configured. Thus Swerdna’s implication that you know about .htaccess files and where they can be created. Maybe yoy should read a little bit in the Apache docs. They are on the internet as Swerdna pointed you to one of the pages within And when your apache server is running, they are on your own system at http://localhost/manual/

When you know more about configuring Apache you know that you can also configure these things centraly in* /etc/apache2/default-server.conf.* E.g. for the DocumentRoot:

<Directory "/srv/www/htdocs">
Order deny,allow
 Deny from all
 Allow from 10.0.0
 Allow from localhost

If you put these lines in

Order deny,allow
Deny from all

Then all is blocked unless /srv/www/htdocs is not the Document Root or some other Directive overrides these lines.

Presumably you altered the file default-server.conf. Please post here the contents
Are you using a .conf file in vhost.d? If “yes” then please post here the contents.

Hi Swerdna,

Your guess is right. The file /etc/apache2/default-server.conf was changed. I am sure I did not make that change.

I added the following tow lines into it.
Order allow,deny
Allow from 10.253.4

Now it works. Only the computers whose IPs match the above specification can access my apache server.

Thanks for your help as well as the help from hccv.


Glad it’s working for you. (a few more tips)