Forum Moderators: phranque

Message Too Old, No Replies

Allowing access from only one domain

         

michaelmichael

4:07 am on Apr 28, 2004 (gmt 0)



Hi,

I am kind of new to apache and am working to make a website that can allow access <i>from only one domain</i> (kind of like an intranet i guess).

I've seen examples on how to block access from a domain, but i'm not sure at how to do the reverse.

Thanks!

jdMorgan

10:32 pm on Apr 28, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



michaelmichael,

Welcome to WebmasterWorld [webmasterworld.com]!

If you are using mod_rewrite or mod_access, simply specify that the {REMOTE_ADDR} must be a specific IP address range, or that {REMOTE_HOST} resolve to the correct domain in order to have access. This latter approach is OK for a small site, but be aware that it invokes a reverse-DNS lookup, and therefore will generate an outgoing DNS lookup for every request to your server. The "user" request coming into your site will have to wait for this DNS lookup to finish before it can proceed. Using an IP address range does not cause this problem.

I couldn't tell from what you posted, but you may want to examine {HTTP_REFERER} instead -- It depends on precisely what you mean by "allow access from one domain". It could mean "allow only one computer named example.com to make requests," or "allow only computers in this specific IP address range to make requests," or you could mean "allow only requests from links on a particular site to access my files."

The implementation details will vary depending on what you want to do and whether you want to use mod_access [httpd.apache.org] or mod_rewrite [httpd.apache.org] to implement access control. To comply with our charter [webmasterworld.com], you should try to write your own code before posting.

Jim