LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-18-2008, 02:57 PM   #1
XeroXer
LQ Newbie
 
Registered: Jun 2008
Location: Västerås, Sweden
Distribution: Arch Linux, Debian, Ubuntu
Posts: 21

Rep: Reputation: 16
Question Apache2 - Limit visitors access based on URL


Hi there.

Have been having some problems with my server lately and thought that now was a good time to solve the problems.

I use the folder /var/www/ as my base web folder, in there I have a folder named default (/var/www/default/) which is the main page that visitors see.
Most people visit the site through the IP (for now: 123.123.123.123) and is then via a .php file sent to 123.123.123.123/default/ .
This works fine except that I also have folders called mine (/var/www/mine/), else (/var/www/else/) and global (/var/www/global/) and I don't want people to be able to visit them through the ip like this 123.123.123.123/global/ .

I only want visitors to be able to see these folders page if coming from a certain URL (global.example.com) and not the IP.
I have it so that the visit through the URL is handled by a VirtualHost rule and sent to the right place, what i can't seem to fix is the problem with the IP still sending the visitor to the subfolder.

If anyone understands what I mean and can help me please do so


-----


I also have a problem with the user for apache2. Standard is set to www-data and group www-data but this causes problems when uploading files via a web form, because then when I ssh in as my user I have no rights to the files.
Can I somehow set a different user for certain VirtualHosts or maybe just change the main apache2 user to my own account, or will this cause any problems along the way?
 
Old 06-18-2008, 04:01 PM   #2
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 63
Create an empty directory in /var/www, let's call it empty, and set your DocumentRoot in your httpd.conf file to /var/www/empty.

Then, all hits to your site for which you do not have a VirtualHost will be directed to the empty directory /var/www/empty.

Setup your VirtualHosts for each of your other directories as you need.

About your permissions question: add your user id as a member of the www-data group and make the web files group writable. Thus, you as a user will be able to write files with www-data group ownership.
 
Old 06-18-2008, 06:11 PM   #3
kenoshi
Member
 
Registered: Sep 2007
Location: SF Bay Area, CA
Distribution: CentOS, SLES 10+, RHEL 3+, Debian Sarge
Posts: 159

Rep: Reputation: 32
If you don't want to change DocumentRoot, use virtual hosts in conjunction with mod_rewrite.

For example, redirect:

123.123.123.123/global
123.123.123.123/else
123.123.123.123/mine

To

123.123.123.123/default

Hope this helps.
 
Old 06-18-2008, 07:43 PM   #4
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 63
Hmmmm.. mod_rewrite is well beyond the scope of most beginners.
 
Old 06-19-2008, 01:19 AM   #5
XeroXer
LQ Newbie
 
Registered: Jun 2008
Location: Västerås, Sweden
Distribution: Arch Linux, Debian, Ubuntu
Posts: 21

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by Mr. C. View Post
Create an empty directory in /var/www, let's call it empty, and set your DocumentRoot in your httpd.conf file to /var/www/empty.

Then, all hits to your site for which you do not have a VirtualHost will be directed to the empty directory /var/www/empty.

Setup your VirtualHosts for each of your other directories as you need.

About your permissions question: add your user id as a member of the www-data group and make the web files group writable. Thus, you as a user will be able to write files with www-data group ownership.
Thanks for the help, this worked just as I wanted. Also the permission solution solved that problem.
 
  


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
URL based restrictions arsridhar Linux - Security 2 03-24-2008 01:36 AM
rewrite rule base url apache2 sinister1 Linux - Software 3 11-23-2007 10:17 AM
Broken multilingual links in apache2 even when url-encoded? michaelsanford Linux - Server 0 10-18-2007 07:04 PM
redirection limit for this url is exceeded phpsharma Programming 3 07-16-2005 03:54 AM
How to limit telnet access to a specific directory based on logon? Saeven Linux - Networking 3 10-20-2002 05:17 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:54 AM.

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