Apache help

MaxBurn

Storage Is My Life
Joined
Jan 20, 2004
Messages
3,245
Location
SC
I would like to run a second instance of apache on a machine already running a pretty much default install.

New instance would be:
-on a different port
-have a base directory on a different drive
-be password protected, nothing crazy like ssl etc, just keep the general runn of the mill people out.


Can I do this, what do you think?
 

MaxBurn

Storage Is My Life
Joined
Jan 20, 2004
Messages
3,245
Location
SC
Second site will be fine. Don't care about a seperate process at all, just has to meet the above. Poor choice in words I guess.
 

Handruin

Administrator
Joined
Jan 13, 2002
Messages
13,931
Location
USA
You can certainly do this with apache's virtual host. All three of your criteria can be met. Apache should spawn a new thread for each connection, so you shouldn't need two installs. This is exactly how storageforum is being host, as a virtual host. We use the default port (80), but all the web pages are served from a different directory. There is one apache instances to serve all the websites on this one physical machine.

If you can map out the specifics of port, directory, I can probably paste the info in this thread that you need to enter in your httpd.conf file.
 

MaxBurn

Storage Is My Life
Joined
Jan 20, 2004
Messages
3,245
Location
SC
Ah, thanks. So something like this here? As my IP may change can I specify wild cards for the virtual host IP or a DNS resolution? What is this "require user rbowen sungo" thing? I didn't see an explination for that in the docs I glanced at.

Thanks for the fast help, I will look into this more after work.

Code:
    ...
    Listen 80
    Listen 8080
    ServerName [url]www.domain.tld[/url]
    DocumentRoot /www/domain

<VirtualHost 111.22.33.44:8080>
	DocumentRoot E:/site2/
	AuthType Basic
	AuthName "Please Login"
	AuthUserFile /usr/local/apache/passwd/passwords
	Require user rbowen sungo
</VirtualHost>
 

Handruin

Administrator
Joined
Jan 13, 2002
Messages
13,931
Location
USA
If your IP address will change, you're better off doing virtual hosting via domain name (DNS) if you can.

The required user is how you password protect the site. rbowen and sungo are two users who have passwords created in "/usr/local/apache/passwd/passwords". There is a process to protect passwords using a provided apache tool. I can also help you with that.

If you'd rather not specify individual users, you can create groups and add users to groups which makes permission handling easier in larger quantities.


Code:
#enter a wildcard "*" as the host since you don't want a static IP
#followed by the port in which apache will listen for this request
#this example uses port 8080
NameVirtualHost *:8080

#add your hostname here
<VirtualHost yourhostname>
#add your hostname aliases here, any name which needs to display your website
ServerAlias hostname.com [url]www.hostname.tld[/url] anothername.hostname.com

#Your e-mail
ServerAdmin [email]webmaster@youraddress.com[/email]

#wherever you want the website server from
DocumentRoot /home/user/public_html

#your hostname
ServerName hostname

#your username
User yourusername

#group of users
Group yourusergroup

#location of CGI
ScriptAlias /cgi-bin/ /home/user/public_html/cgi-bin/

#Authentication section below

#type of authentication
AuthType Basic

#message to display
AuthName "Message to display in login box"

#location of username/password file
AuthUserFile  	/location/of/file/file

#location of group file
AuthGroupFile /location/of/groupfile/file

#authentication requirements (users granted access)
Require username1 username2

#using group authentication uncomment the following
#Require group usergroup1

</VirtualHost>

More information about apache authentication here. If you need more security with the logins, you may want to consider a digest authentication.

More infor on the apache core directives found here.
 

MaxBurn

Storage Is My Life
Joined
Jan 20, 2004
Messages
3,245
Location
SC
I don't need the user group setup, only going to have a couple users. I just didn't realize they stored the user name in the CFG file itself instead of increpted somewhere else along with the passwords. This whole thing is more for easy access for me on the road (like today! and whats up with business hotels that don't have broadband?)

I am currently using a free dynamic DNS service, can't remember what the name is but it's whatever servs up ath.cx. That will work for the below setup right? The <VirtualHost yourhostname> line would then end up with <VirtualHost scottjal.ath.cx> correct?


I can specify drive letters here right? This has no whitespaces allowed in the directorys?
#wherever you want the website server from
E:/PublicFolder/Files


What is this for, do I need it? All my content will by static, no dynamic stuff at all.
#location of CGI
ScriptAlias /cgi-bin/ /home/user/public_html/cgi-bin/


So I can paste this right in the bottom of the CFG file or does it need to replace some stuff in there, sorry I am away right now and can't look at it at the moment.

Code:
#enter a wildcard "*" as the host since you don't want a static IP 
#followed by the port in which apache will listen for this request 
NameVirtualHost *:33000 

#Don't I need to tell it to listen to the ports? or does the above replace
#this somehow?
    Listen 80 
    Listen 33000 

#add your hostname here 
<VirtualHost scottjal.ath.cx:33000> 
#add your hostname aliases here, any name which needs to display your website 
ServerAlias scottjal.ath.cx

#Your e-mail 
ServerAdmin [email]me@here.com[/email]

#wherever you want the website server from 
DocumentRoot E:/PublicFiles/

#your hostname 
ServerName hostname 



#Authentication section below 

#type of authentication 
AuthType Basic 

#message to display 
AuthName "Please Login" 

#location of username/password file 
AuthUserFile     /location/of/file/file 

#your usernames
Require user name1 name2 etc

</VirtualHost>
 

MaxBurn

Storage Is My Life
Joined
Jan 20, 2004
Messages
3,245
Location
SC
OK, I created my password file and added in the below to the httpd.conf

Listen 33000
<VirtualHost *:33000>
DocumentRoot E:/Public Files/
ServerName scottjal.ath.cx
ErrorLog logs/fileaccesserror.log
AuthType Basic
AuthName "Please Login"
AuthUserFile Apache2\bin\user
Require user user1
</VirtualHost>

The service won't start nor will it log any errors in the error log. Or anything at all for that matter with the log level set to debug. Any obvious errors here?
 

Handruin

Administrator
Joined
Jan 13, 2002
Messages
13,931
Location
USA
I think part of the reason could be this.

I took your config and tried it on my setup line by line, and this is what I found:

Listen 33000
<VirtualHost *:33000>
###---Must use quotes--###
DocumentRoot "E:/Public Files/"

ServerName scottjal.ath.cx

###---Must use quotes--###
ErrorLog "logs/fileaccesserror.log"
AuthType Basic
AuthName "Please Login"

###---Must supply the full path to the user file--###
AuthUserFile Apache2\bin\user
Require user user1
</VirtualHost>


Basically I tried starting my apache while uncommenting each directive one by one until it failed on AuthType. I think apache can't find the user file, so apache fails during boot. Also, don't forget to add the "NameVirtualHost" tag.
 

MaxBurn

Storage Is My Life
Joined
Jan 20, 2004
Messages
3,245
Location
SC
Thanks, now have some real progress. This works:

Code:
<VirtualHost *:33000> 
DocumentRoot "E:/Public Files/" 
ServerName scottjal.ath.cx 
ErrorLog "logs/fileaccesserror.log"
#AuthType Basic 
#AuthName "Please Login"
#AuthUserFile "bin\user\pass"
#Require user user1
</VirtualHost>

After haveing to remember to punch a hold in the firewall I got a page that says:
Forbidden
You don't have permission to access / on this server.
Apache/2.0.53 (Win32) Server at scottjal.ath.cx Port 33000

Also loggs this error: [Sat Sep 03 10:38:18 2005] [error] [client 64.222.174.183] Directory index forbidden by rule: E:/Public Files/
[Sat Sep 03 10:40:27 2005] [error] [client 64.222.174.183] Directory index forbidden by rule: E:/Public Files/

Also with the security portion not remarked out it will not launch, still something wrong there. Do you mean the full path from C: or just the install directory like I have above?
 

MaxBurn

Storage Is My Life
Joined
Jan 20, 2004
Messages
3,245
Location
SC
Oh, and I did use htpasswd.exe to create a password file. I didn't put a file extention on the file though, does it need it you think?
 
Top