Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have two virtual hosts on one server: srv-08.zone08.edu:80 tulip.zone08.edu:8088

I need to get nothing, when I put srv-08.zone08.edu:8088.

File /etc/apache2/ports.conf:

NameVirtualHost srv-08.zone08.edu:80
NameVirtualHost tulip.zone08.edu:8088
Listen 80
Listen 8088

File config srv-08.zone08.edu (few first lines):

<VirtualHost srv-08.zone08.edu:80>
  ServerAdmin admin@zone08.edu
  ServerName srv-08.zone08.edu
***

File config tulip.zone08.edu (few first lines):

<VirtualHost tulip.zone08.edu:8088>
  ServerAdmin admin@zone08.edu
  ServerName tulip.zone08.edu
***

I think, it's enough to change VirtualHost (it was just ) and NameVirtualHost. But it's not enough... ( And in this way, my hosts aren't visible from other connected pc. Any ideas?

Cofig file:

<VirtualHost tulip.zone08.edu:8088> 
  ServerAdmin admin@zone08.edu 
  ServerName tulip.zone08.edu 
  DocumentRoot /usr/apache 
  ErrorLog /home/usr/apache2.log 

  RewriteEngine on 
  RewriteCond %{HTTP_HOST} srv-08.zone08.edu 
  RewriteRule (.*) http://srv-08.zone08.edu/$1 

  <Directory "/usr/apache"> 
    Options Indexes MultiViews FollowSymLinks 
    AllowOverride None 
    Order deny,allow 
    Deny from all 
    Allow from all 
  </Directory> 
</VirtualHost>

Config is right. everything works, except RewriteEngine and right hostnames

share|improve this question

1 Answer 1

up vote 0 down vote accepted

Since you have them on the same server, and the server is listening to both ports, you cannot get just nothing when you connect to a port that Apache is actually handling. There are some various things you can do, that may or may not be what you want, though. I'll try to see if I can help you with them.

First, it's better to put the IP address of the system rather than the hostname in your config file. That way, even if you are having DNS troubles, it won't confuse Apache.

Here's a new config for the tulip server, just remember to put your own actual IP address instead of 1.2.3.4 that I'm using. You also need to fix a path to a usable log fiel where I've written PATH-TO-LOGFILE

<VirtualHost 1.2.3.4:8088> 
  ServerAdmin admin@zone08.edu 
  ServerName tulip.zone08.edu 
  DocumentRoot /usr/apache 
  ErrorLog /home/usr/apache2.log 

  RewriteEngine on 
  RewriteLog PATH-TO-LOGFILE
  RewriteLogLevel 3
  RewriteCond %{HTTP_HOST} srv-08.zone08.edu 
  RewriteRule (.*) http://srv-08.zone08.edu/$1 [R,L]

  <Directory "/usr/apache"> 
    Options Indexes MultiViews FollowSymLinks 
    AllowOverride None 
    Order deny,allow 
    Deny from all 
    Allow from all 
  </Directory> 
</VirtualHost>

I fixed another spelling error, you had /VintualHost instead of /VirtualHost, and I added some logging for the rewrite procedure. Once you get it running the way you want, you can remove the RewriteLog and RewriteLogLevel lines, but for now you'll need them to figure out anything I may have misunderstood.

share|improve this answer
    
Hmm... Where I need add this? In config host tulip or to ports? Because when I add this to tulip config - apache2 got error. As about task... Teacher told me make access to host using name and port... But works as only port.... –  Corwin May 10 '12 at 12:54
    
How did the config look when you had added it? What error did you get? –  Jenny D May 10 '12 at 12:56
    
Sorry, I don't know how to make comment with code block ( as for error - it seems that debian can't read command "RewriteEngine"... "Invalid command "RewriteEngine", perhaps misspelled or defined by a module not included in the server configuration. –  Corwin May 10 '12 at 13:59
    
Could you please copy and paste the configuration into your question instead? It's very unreadable in the comments. Also, there's at least one spelling error - you've got <Direcroty> instead of <Directory>, which may be part of the problem. But it's really hard to read in the comment, there may be something else. –  Jenny D May 10 '12 at 14:00
    
It seems, that thatever I do - server linked hosts via ports, but not Name:port –  Corwin May 10 '12 at 14:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.