2012-11-27 106 views
2

我真的不知道如何解決這個問題。我需要在地址http://sub.domain.com/上加載頁面http://domain.com:12345/爲端口創建別名

當我只有一個IP地址時,我應該如何在Apache上設置VirtualHost或Alias?

非常感謝。


現在我眼前這個:

ports.conf:

NameVirtualHost domain.com:80 
NameVirtualHost sub.domain.com:80 
Listen *:80 

<IfModule mod_ssl.c> 
    Listen *:443 
</IfModule> 

<IfModule mod_gnutls.c> 
    Listen *:443 
</IfModule> 

... /站點可用/默認:

<VirtualHost domain.com:80> 
     ServerAdmin [email protected] 
     ServerName domain.com 
     DocumentRoot /var/www 
     ... 
</VirtualHost> 

<VirtualHost sub.domain.com:80> 
     ServerAdmin [email protected] 
     ServerName sub.domain.com 
     ProxyPass/http://www.domain.com:12345/ 
     ProxyPassReverse/http://www.domain.com:12345/ 
</VirtualHost> 

但這並不工作。 sub.domain.com返回500內部服務器錯誤。

回答

0

該解決方案是虛擬主機:

如果你想你的 機上保持多個域/主機名,你可以通過設置虛擬容器他們。大多數配置 僅使用基於名稱的虛擬主機,因此服務器無需擔心IP地址爲 。這在下面的指令中用星號表示。

請參閱在 http://httpd.apache.org/docs/2.2/vhosts/ 更多詳細信息,文檔,試圖設置虛擬主機前。

您可以使用命令行選項'-S'來驗證您的虛擬主機 配置。

這裏來配置示例:

# 
# Use name-based virtual hosting. 
# 
NameVirtualHost *:80 

# 
# VirtualHost example: 
# Almost any Apache directive may go into a VirtualHost container. 
# The first VirtualHost section is used for all requests that do not 
# match a ServerName or ServerAlias in any <VirtualHost> block. 
# 
<VirtualHost *:80> 
    ServerAdmin [email protected] 
    DocumentRoot "C:/Program Files (x86)/www/htdocs/dummy-host.localhost" 
    ServerName dummy-host.localhost 
    ServerAlias www.dummy-host.localhost 
    ErrorLog "logs/dummy-host.localhost-error.log" 
    CustomLog "logs/dummy-host.localhost-access.log" combined 
</VirtualHost> 

<VirtualHost *:80> 
    ServerAdmin [email protected] 
    DocumentRoot "C:/Program Files (x86)/www/htdocs/dummy-host2.localhost" 
    ServerName dummy-host2.localhost 
    ServerAlias www.dummy-host2.localhost 
    ErrorLog "logs/dummy-host2.localhost-error.log" 
    CustomLog "logs/dummy-host2.localhost-access.log" combined 
</VirtualHost>