允许子域指向计算机的Apache2配置:端口

时间:2012-07-19 16:26:15

标签: ruby-on-rails apache2 config virtualhost

我拥有域名“peterlee.com.cn”,并在我的域控制面板中添加了A记录:

RR                  Destination IP   TTL
rs.peterlee.com.cn  10.50.10.75      1 hour

我在10.50.10.75:9051上运行了一个RoR(Ruby on Rails)项目,这意味着用户可以通过http://10.50.10.75:9051访问我的RoR应用程序

我想让用户通过http://rs.peterlee.com.cn访问它,因此我添加了以下VirtualHost文件/网站:

<VirtualHost *:80>
    ServerName rs.peterlee.com.cn
    DocumentRoot /usr/website/myapp/current/public
    PassengerEnabled off
    ProxyPass / http://127.0.0.1:9051/
    ProxyPassReverse / http://127.0.0.1:9051/
    RackEnv production
    RailsEnv production

    <IfModule mod_rewrite.c>
        RewriteEngine On

        # Redirect all requests to the maintenance page if present
        RewriteCond %{REQUEST_URI} !\.(css|gif|jpg|png)$
        RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
        RewriteCond %{SCRIPT_FILENAME} !maintenance.html
        RewriteRule ^.*$ /system/maintenance.html [L]
    </IfModule>

</VirtualHost>

启用站点并重新启动Apache2后,我尝试http://rs.peterlee.com.cn,它给了我500内部服务器错误:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, [no address given] and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Apache/2.2.22 (Ubuntu) Server at rs.peterlee.com.cn Port 80

感谢。

彼得

1 个答案:

答案 0 :(得分:1)

我在/var/log/apache2/error.log中发现了以下警告:

[Thu Jul 19 10:22:20 2012] [warn] proxy: No protocol handler was valid for the URL /. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule.
[Thu Jul 19 10:22:20 2012] [warn] proxy: No protocol handler was valid for the URL /favicon.ico. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule.

所以我启用了以下模块:

sudo a2enmod proxy proxy_balancer proxy_http

重启Apache2后,它运行了!

非常感谢。

BTW:我使用Passenger启动服务:

passenger start -a 127.0.0.1 -p 9051 -e production -d