LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 03-09-2006, 07:53 PM   #1
pdeman2
Member
 
Registered: Jul 2005
Location: Maine, USA
Distribution: OpenSUSE, Gentoo, Fedora, Ubuntu, Mandriva, others
Posts: 413

Rep: Reputation: 30
Apache virtual hosts behind a router??


I've been hosting a website from my computer for a while now, and all has gone well. Now, I need to add another website. I'm not sure I understand much about virtual hosts.

My computer is connected to the internet through a router. That router currently forwards anything on port 80 to my computer (192.168.0.100). I have two registered domain names that I want to use (one for each website), both domain names are currently connected to my router's IP address. I've read about IP aliasing, but I don't know how to use that when I'm behind a router. How should I go about setting this up?
 
Old 03-09-2006, 08:05 PM   #2
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141

Rep: Reputation: 168Reputation: 168
If you already have one domain name set up (through a ddns provider like http://www.dyndns.com/?) and the requests are being forwarded to your web server through your router, then you're most of the way there.

It sounds like your second domain is already pointing at your IP address, so your router will forward the request to your web server. However, your web server won't recognise the domain so the best you'd get at this point is the default web page - or just an error.

Apache's virtual hosts can handle this situation. I have several domains on one of my boxes configured initially from the docs at http://httpd.apache.org/docs/2.0/vhosts/. As long as you don't need multiple https sites on one IP address everything you need is either there or at http://httpd.apache.org/docs/2.0/vhosts/name-based.html.
 
Old 03-09-2006, 08:15 PM   #3
rjcrews
Member
 
Registered: Apr 2004
Distribution: Debian
Posts: 193

Rep: Reputation: 30
My Vhosts.conf file, this may help:

Code:
<VirtualHost *:80>
ServerName www.yyy.com
ServerAlias yyy.com *.yyy.com
DocumentRoot /var/www/html
ErrorLog logs/yyy.com-error_log
TransferLog logs/yyy.com-access_log
</VirtualHost>

<VirtualHost *:80>
ServerName www.xxx.com
ServerAlias xxx.com *.xxx.com
DocumentRoot /var/www/html/xxx
ErrorLog logs/xxx.com-error_log
TransferLog logs/xxx.com-access_log
</VirtualHost>
 
Old 03-09-2006, 09:19 PM   #4
pdeman2
Member
 
Registered: Jul 2005
Location: Maine, USA
Distribution: OpenSUSE, Gentoo, Fedora, Ubuntu, Mandriva, others
Posts: 413

Original Poster
Rep: Reputation: 30
Okay, the virtual hosts seem to be pointing to the directory, but now I have another problem. Since I've added this new website, I'm having authentication problems. I've looked through my httpd.conf and I created a new password file. Authentication works for one website, but not the other.
 
Old 03-09-2006, 09:46 PM   #5
routers
Member
 
Registered: Aug 2005
Location: Malaysia - KULMY / CNXTH
Distribution: Slackware, Fedora, FreeBSD, Sun O/S 5.10, CentOS
Posts: 787
Blog Entries: 6

Rep: Reputation: 75
this is my <VirtualHost> sample , i think u can figure out how to add more than one site on the system

<VirtualHost *>
ServerName rou.homelinux.net
ServerAdmin noc@rou.homelinux.net
DocumentRoot /export/site/noc/www
TransferLog /export/site/noc/logs/access-log
ScriptAlias /cgi-bin/ /export/site/noc/www/cgi-bin/
</VirtualHost>

<VirtualHost *>
ServerName fm.homelinux.net
ServerAdmin fm@fm.homelinux.net
DocumentRoot /export/site/fm/www
TransferLog /export/site/fm/logs/access-log
ScriptAlias /cgi-bin/ /export/site/fm/www/cgi-bin/
</VirtualHost>
 
Old 03-09-2006, 10:03 PM   #6
pdeman2
Member
 
Registered: Jul 2005
Location: Maine, USA
Distribution: OpenSUSE, Gentoo, Fedora, Ubuntu, Mandriva, others
Posts: 413

Original Poster
Rep: Reputation: 30
Thanks, routers, but as I wrote in my last post, the virtual host setup is working good, but now authentication is not working correctly
 
Old 03-09-2006, 10:10 PM   #7
routers
Member
 
Registered: Aug 2005
Location: Malaysia - KULMY / CNXTH
Distribution: Slackware, Fedora, FreeBSD, Sun O/S 5.10, CentOS
Posts: 787
Blog Entries: 6

Rep: Reputation: 75
ok see example
1st domain
DocumentRoot /export/site/noc/www

2nd domain
DocumentRoot /export/site/fm/www

place it in user home directory i think this will solve "authentication"

noc and fm is diffrent user , see my etc/passwd

noc:x:1001:100:noc,,,:/export/site/noc:/usr/bin/passwd
fm:x:1003:100:freeman,,,:/export/site/fm:/usr/bin/passwd
 
Old 03-09-2006, 10:49 PM   #8
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141

Rep: Reputation: 168Reputation: 168
What is your set up for the directories requiring it on the virtual host that isn't working? I usually have something like the following:
Code:
<Directory "/var/www/html/attach">
  Options Indexes FollowSymLinks
  IndexOptions FancyIndexing FoldersFirst IgnoreCase VersionSort NameWidth=*
  AllowOverride None
  Order allow,deny
  Allow from all
  AuthType Basic
  AuthName "Attachments"
  AuthUserFile /usr/local/apache2/passwd/passwords
  Require user guest
</Directory>
 
Old 03-10-2006, 06:36 AM   #9
pdeman2
Member
 
Registered: Jul 2005
Location: Maine, USA
Distribution: OpenSUSE, Gentoo, Fedora, Ubuntu, Mandriva, others
Posts: 413

Original Poster
Rep: Reputation: 30
Well, I'm at school right now, so I cant really post anything from conf files or any thing, but hear is what one of my directory setups looks like:
Code:
<Directory /srv/www/htdocs/>
  Order allow,deny
  Allow from all
  AuthType Basic
  AuthName "SuSE Server"
  AuthUserFile /srvpass/apache2/.passwords
  Require user user
</Directory>
This isn't exactly what I have, but it is very similar.
 
Old 03-10-2006, 02:30 PM   #10
pdeman2
Member
 
Registered: Jul 2005
Location: Maine, USA
Distribution: OpenSUSE, Gentoo, Fedora, Ubuntu, Mandriva, others
Posts: 413

Original Poster
Rep: Reputation: 30
Alright, I figured it out, I was doing something stupid. I was using htpasswd2 -c for each new user I was adding. Every time I added someone new, the passwd file was recreated.

Everything is working fine now. Thanks for the help everyone.
 
  


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
vsftpd, web uploads, vsftpd virtual users, apache virtual hosts, home directories jerryasher Linux - Software 7 02-18-2007 06:29 AM
apache virtual hosts smaida Linux - Software 3 06-20-2004 04:28 PM
Apache Virtual Hosts gbg Linux - Software 4 10-02-2003 08:35 AM
Apache virtual hosts Mil0 Linux - Software 5 06-01-2003 11:58 PM
Apache Virtual Hosts (again) scatcat Linux - General 1 10-17-2002 09:51 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 09:00 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