允许一个子域指向一个机器

允许一个子域指向一个机器

本文介绍了Apache2的配置,允许一个子域指向一个机器:端口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我自己的域名,peterlee.com.cn,我在我的域名控制面板增加了一个A记录:

I own the domain, "peterlee.com.cn", and I added an A Record in my domain control panel:

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

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

I have an RoR (Ruby on Rails) project running on 10.50.10.75:9051, which means the user can visit my RoR application by http://10.50.10.75:9051

我想让用户通过参观,所以我加了下面的虚拟主机文件/网站:

I want to let the user visit it by http://rs.peterlee.com.cn, so I added the following VirtualHost File/Site:

<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内部服务器错误:

After enabling the site and restarting the Apache2, I tried http://rs.peterlee.com.cn, it gives me the 500 Internal Server Error:

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

感谢。

彼得

推荐答案

我发现下面的警告 /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.

所以我启用以下模块:

So I enable the following modules:

sudo a2enmod proxy proxy_balancer proxy_http

重新启动的Apache2后,它的工作!

After restarting Apache2, it worked!

不管怎样,谢谢。

BTW:我开始使用客运服务:

BTW: I start the service using Passenger:

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

这篇关于Apache2的配置,允许一个子域指向一个机器:端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!