3

I have 2 virtual hosts(bugzilla and board review) on an apache server sitting inside an ubuntu machine.

I have one external ip address I can use(with one port enabled) so I can't assign different host names or different ports for the virtual hosts.(correct me if I'm wrong)

I want the user to be able to write the following: http://ip-address:port/bugzilla and for the requests to go to bugzilla and for requests from http://ip-address:port/review to go to the review board.

I tried reverse proxying from the first vhost to the second but that didn't work.

The bugzilla conf file uses cgi and the review board uses wsgi.

Is there a simple way of accomplishing the above?

Thanks in advance.

2 Answers 2

6

You can achieve this using the Alias directive.

The Alias directive allows documents to be stored in the local filesystem other than under the DocumentRoot. URLs with a (%-decoded) path beginning with URL-path will be mapped to local files beginning with directory-path. The URL-path is case-sensitive, even on case-insensitive file systems.

Alias "/image" "/ftp/pub/image" A request for http://example.com/image/foo.gif would cause the server to return the file /ftp/pub/image/foo.gif. Only complete path segments are matched, so the above alias would not match a request for http://example.com/imagefoo.gif. For more complex matching using regular expressions, see the AliasMatch directive.

Your Virtual host file would look like this

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName ip-address:port/bugzilla 
    Alias "/bugz" "var/www/html/bugz"
    Alias "/wow" "var/www/html/wow"    
    DocumentRoot /path/to/yourwebsite  
</VirtualHost>

Achieving your goal of having multiple virtual hosts on the same IP.

GIF of it working

enter image description here

NOTE

  • This is working for Apache 2.4.18
  • The GIF shows a VirtualHost configuration with two different virtual host entries. One of the comments to this answer said different virtual hosts don't work. But they do, as long as the server name is different.
0
1

You could change your addresses so they're http://bugzilla.ip-address:port/ and http://review.ip-address:port/ and then use the ServerName directive to use the correct VirtualHost.

http://httpd.apache.org/docs/2.0/vhosts/examples.html

1
  • Thanks for your reply, It seems a bit problematic on my end... The external ip goes through another server and unfortunately only a url that starts with ip-address::port/url-suffix is passed to the apache server.
    – Jonathan
    Oct 5, 2011 at 16:31

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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