LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 12-19-2015, 02:38 PM   #1
johannes.kepler
LQ Newbie
 
Registered: Jun 2007
Posts: 9

Rep: Reputation: 0
Allow only some domains in .htaccess


Hi,

I'm trying to allow only certain domais and subdomains to access a specific folder in my domain.

Actually, I have one subdomain, sub.domain.com, in a dir called sub in my domain.com

What I want is that the user must call one page like sub.domain.com/page.html but from the right referrer.
No other domains might call it unless they are authorized (like domain1.com or domain2.com for instance)

Also, in those authorized domains, they migh be in the form www.domain1.com

I'm trying the following:

AuthType Basic
<Limit GET>
order deny,allow
deny from all
allow from .domain.com
allow from .sub.domain.com
allow from .domain1.com
allow from .domain2.com
</Limit>

but I get an 403 for all!!!

Any ideas?

Kind regards,

JKepler

Last edited by johannes.kepler; 12-19-2015 at 07:53 PM.
 
Old 12-21-2015, 07:18 AM   #2
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,308
Blog Entries: 3

Rep: Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721
(I'd move your tries out of .htaccess and put it in the proper configuration file, if you have access. Use of the .htaccess files is generally to be avoided because it complicates things, usually unnecessarily.)

About allow and deny, they are affected by the host the user is actually connecting from and have nothing to do with the "referer" field. What you'll want will most likely involve using variables inside Apache. Here is a starting point:

https://httpd.apache.org/docs/2.4/en...ml#image-theft

Note that headers can be forged so you are not going to be providing any serious access control using that method, just a nudge in the direction you want.
 
Old 12-23-2015, 09:34 AM   #3
johannes.kepler
LQ Newbie
 
Registered: Jun 2007
Posts: 9

Original Poster
Rep: Reputation: 0
Hi,

I thought in using the Javascript hostname variable. But can this be faked as well? I've made a small script that checks this variable and if it's different of the authorized webasite A it redirects to a denied.html page. The hacker can read the code, but can he change it?

Another idea is this:
- the website A calls a script from my website requesting a key (which contains - encrypted) the date and time of the request). This key is saved both in website A and mine (website B) in file.txt
- The website A calls then the main script. My website checks the referer, and pulls the info from file.txt It checks then the information saved from both servers. If there's no match, the request is denied.

I think this might work; the hacker cannot change the info in file.txt - he can only read it. But my script will get the info only from the authorized website A. If the referer is spoofed, file.txt is not. file.txt is, in fact, a sort of the "website A cookie"....

Can this work?...

Regards,

JKepler
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to redirect to three different domains with .htaccess? plotinus Linux - Server 2 11-24-2011 12:38 AM
Multiple emails accounts(with different from domains) on multiple domains on 1 server locoputo Linux - Server 0 04-12-2009 06:29 PM
Multiple domains in LDAP and 1 samba server for all domains, what to do? xnomad Linux - Server 1 11-14-2008 09:12 AM
Addon Domains dont load with .htaccess Html33 Linux - Server 1 07-21-2008 11:05 AM
Sub Domains & Multiple Domains (Apache) lugos Linux - Server 1 09-01-2006 10:22 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 05:19 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration