Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Is it wise (&feasible) for me to use .htaccess file for my application??

Posted on 2004-08-30
10
307 Views
Last Modified: 2010-03-04
Hi Mr. Hoffman and Mr. Samri,
How u doin? Well i want to clarify that is it wise and feasible to write .htaccess file for my application which will be live24/7 to thousands of users. Actually if you remember i have been constantly taking your and Samri's able guidance for hosting my application live. Still to refresh your memory i posted my query at (http://www.experts-exchange.com/Web/Web_Servers/Apache/Q_21100303.html). I have almost implemented all the things which you guys suggested. My envt is RHL 9.0/ Apache2.0 with mod_mono/ Mono 1.0. The users will be accessing some other directories too in the main application directory. e.g if i have placed the application directory "apps" as under /var/www/html/apps, now in this apps directory i have some other directories which the users will be needing to retrieve some data for thier use. Should i check for the authentication at that level tool? All I want is that only valid users may have access to that data. Although at the first entry point the .NET applcation asks for the authentication of the valid user but i was still wondering from my, i mean Apache's point of view. I dont know whether this is a valid question or not and i think you are in a better position to guide me. So from that point of view what do you suggest? I would really appreciate if you could guide me step by step...
Thanks in advance
Regards!!
0
Comment
Question by:parvinderg
  • 4
  • 4
  • 2
10 Comments
 
LVL 15

Expert Comment

by:samri
ID: 11934316
hi parvinderg,

i am almost off to bed.

Regarding validity -- yes, as long as your question has "apache" word in it. :)

So we are looking at the following directory tree:

/var/www/html
/var/www/html/apps
/var/www/html/otherstuff
...

and quick answer, YES, you could use .htaccess to protect the stuff in any folder.  But first, jump to the usual :
http://httpd.apache.org/docs-2.0/howto/auth.html on protection and stuff.
http://httpd.apache.org/docs-2.0/howto/htaccess.html on more info on .htaccess

Most of the information is pretty much laid down by the Apache team there.

Basically, once you had protected the a directory (either in .htaccess in that folder, or in <Directory>.. tag in server config), the ACL is pretty much inherited to the folder underneath.  As for your directory tree-- if you had protected /var/www/html/apps, andything /var/www/html/apps/apps1, /var/www/html/apps/apps2, /var/www/html/apps/apps3 etc. would be protected.  Any access to any resource within that directory tree would be greeted with a password pop-up box.

Hope this could give you a kick start.

0
 
LVL 15

Expert Comment

by:samri
ID: 11934332
Addition:  You may take a look at Apache FAQ at http://httpd.apache.org/docs/misc/FAQ.html
Specif section : "G. Authentication and Access Restrictions"

cheers.
0
 

Author Comment

by:parvinderg
ID: 11934632
Thx Samri....I will just implement all these things and let u know..I m in US...btw where dya live?

Regards
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 38

Expert Comment

by:yuzh
ID: 11940020
If you don't like the .htaccess files in all over the place, you can use ONE file to crontrol
the login access. (eg: access.conf, or what evername you want to called it).

Just make sure that you httpd.conf has something looks like:

AccessConfig /etc/apache/access.conf


0
 
LVL 38

Assisted Solution

by:yuzh
yuzh earned 150 total points
ID: 11940046
also have a look at:
http://www.itlab.musc.edu/mySiteMaker/LOGGING-HOWTO.html

"<Limit GET POST>
require valid-user
</Limit>"

 apply to the access.conf, so you can control the user login for the dir.
0
 
LVL 15

Expert Comment

by:samri
ID: 11945943
parvinderg,

Somewhere in GMT+8 timezone.  It's in Kuala Lumpur - *just woked up after 8 hours of hibernation :)
0
 

Author Comment

by:parvinderg
ID: 11956122
Hi Samri...
How u doin? It all great here:). Samri can u please help me in clarifying something about protecting server files in context to my case. How can i implement it when it comes to my application. What syntax do i need to write?
This is the link about which i need some explaination.
http://httpd.apache.org/docs-2.0/misc/security_tips.html#protectserverfiles
Regards
0
 

Author Comment

by:parvinderg
ID: 11956136
can u explain especially about :
<Directory /usr/users/*/public_html>
Regards
0
 
LVL 15

Accepted Solution

by:
samri earned 350 total points
ID: 11973052
Hi parvinderg,

First of all, the URL that you mentioned is pretty much straighforward.  

# cd /; ln -s / public_html
Accessing http://localhost/~root/

simply means that you create a symbolic link for user root (since most root will have their home directory to be in / - the root of the filesystem) - for some reason that I could not think of.  The command, would create a symbolic_link public_html, to the root, so anybody that does http://yourserver/~root/ would actually be looking at /, since by default Options (http://httpd.apache.org/docs-2.0/mod/core.html#options) is set to All.  You could explicitly do Option -FollowSymlinks to disable traversal of symlinks.  However this would impose a different problem later on.

Next option would be following the recommendation from Apache website (since they knew the stuff better :);

<Directory />
Order Deny,Allow
Deny from all
</Directory>

This would, by default deny access to all parts of filesystem.  For each, access that is required, you would need to explicitly add the <Directory>... </Directory> tag to enable them.

The "<Directory /usr/users/*/public_html>" would cause a wildcard (*) match for any folder that is /usr/users/username/public_html> to be substituted.  So you practically do not need to add a Directory tag for each users.  Also look at UserDir directive (http://httpd.apache.org/docs-2.0/mod/mpm_common.html#user) for a directive complementing this.

0
 

Author Comment

by:parvinderg
ID: 11977857
Thanks a lot Samri and yuzh...
Regards
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my time as an SEO for the last 2 years and in the questions I have assisted with on here I have always seen the need to redirect from non-www urls to their www versions. For instance redirecting http://domain.com (http://domain.com) to http…
If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question