如何将子域转发到一个新的端口上相同的IP地址? [英] How to forward a subdomain to a new port on the same IP address?

查看:148
本文介绍了如何将子域转发到一个新的端口上相同的IP地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个NAS /服务器在家24/7运行,并在其上​​运行许多不同的服务。我有一个域名指向它,现在,想知道是否有可能创建子域指向不同的服务不同的端口。例如:

I have a NAS/Server running at home 24/7 and run many different services on it. I have got a domain name pointing to it now, and was wondering if it would be possible to create sub-domains that point to different ports for different services. For example:

  • http://subsonic.mydomain.com --> XXX.XXX.XXX.XXX:4040
  • http://minecraft.mydomain.com --> XXX.XXX.XXX.XXX:25565
  • http://files.mydomain.com --> XXX.XXX.XXX.XXX:4082

我有一个单一的D-LINK路由器的当前端口的所有这些端口转发到我的NAS /服务器的IP是192.168.0.104。

I have a single D-LINK router that currently port forwards all these ports to my NAS/Server whose IP is 192.168.0.104.

编辑:服务器正在运行的Ubuntu 12.04

The server is running Ubuntu 12.04.

哪些服务或代理,我需要运行可相应确认的子域和路由的流量?或者,我可以使用Apache的虚拟主机来处理这一点,因为这些子域名会在80端口,这Apache是​​在听什么?还是虚拟主机不喜欢这个工作?

What service or proxy do I need to run that can recognize the sub domain and route the traffic accordingly? Or could I use apache virtual hosts to handle this, because these subdomains will come in on port 80, which apache is listening to? Or does virtual hosts not work like this?

任何信息,想法,或提示会很有帮助/有用的。

Any information, ideas, or tips would be helpful/useful.

推荐答案

有两种方法可以做到这一点。你可以使用的虚拟主机部分中的的httpd.conf 或者你可以做你的的.htaccess 。 (假设子域解析到同一个IP为你的网络服务器)

There are two ways to do this. You could use the VirtualHost section of your httpd.conf or you could do it in your .htaccess. (assuming that the subdomains resolve to the same IP as your webserver)

的httpd.conf

<VirtualHost *:80>
    ServerName subsonic.mydomain.com
    redirect / http://mydomain.com:4040/
</VirtualHost>

的.htaccess

RewriteEngine on
RewriteCond %{HTTP_HOST} ^subsonic\.mydomain\.com$ [NC]
RewriteRule ^(.*)$ http://mydomain.com:4040/$1 [R=301]

文件:

  - 指南创建基于域名的虚拟主机

  - 核心,其中的VirtualHost 了NameVirtualHost

  - 重定向

  - mod_rewrite的指南

这篇关于如何将子域转发到一个新的端口上相同的IP地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆