多个域指向 apache 服务器中的不同端口
我正在使用一个 Web 开发框架,该框架在 apache 服务器端口:8080、8081、8082 等中发布其应用程序。
例如 MyApp1 在 localhost:8080 中运行,MyApp2 在 localhost:8081 中运行,依此类推。
我想要实现的是,我的域指向一个“端口”,其应用程序在我的 apache Web 服务器中运行,例如 www.mydomainclient1.com 应指向 8080 端口和 www.mydomainclient2。 com 应指向 8081 端口。
我所做的就是进入我的域名提供商网站,然后转到 Total DNS Control 并将这些域指向我的专用服务器 IP。
现在,我的域指向 mydedicatedserverIP,因此当我执行 www.mydomainclient1.com 和 www.mydomainclient2.com 时,它们都会访问 mydedicatedserverIP,默认为 80 端口。
我试图解决的情况是:
我想让 www.mydomainclient1.com 直接指向 mydedicatedserverIP:8080 和 www.mydomainclient2.com 指向 mydedicatedserverIP:8081。
您认为对此有什么好的解决方案吗? (我希望我的问题足够清楚,因为我不是一个以英语为母语的人,正如你所看到的)
环境:Linux Debian 5 Lenny,Apache Server 2.2.9-10+lenny8
由于我是 apache 服务器的新手,任何评论或建议都会非常感谢,即使您认为这是显而易见的:-)。
I am working with a web development framework which publish its applications in apache server ports:8080, 8081, 8082, etc.
For instance MyApp1 runs in localhost:8080, MyApp2 runs in localhost:8081, and so on.
What I would like to achieve is that my domains point to a "port" where its application is running in my apache web server, e.g. www.mydomainclient1.com should point to 8080 port and www.mydomainclient2.com should point to 8081 port.
What I have done is I have entered to my Domain Name Provider web site, then went to Total DNS Control and point these domains to my dedicated server IP.
Now, my domains point to mydedicatedserverIP, so when I do www.mydomainclient1.com and www.mydomainclient2.com they both access mydedicatedserverIP, by default 80 port.
The situation I am trying to solve is:
I'd like to have www.mydomainclient1.com pointing directly to mydedicatedserverIP:8080 and www.mydomainclient2.com pointing to mydedicatedserverIP:8081.
What do you think would be a good solution for this?
(I hope my question is clear enough due I am not a native english speaker as you can see)
Environment: Linux Debian 5 Lenny, Apache Server 2.2.9-10+lenny8
As I am a newbie in apache server any comment or suggestion will be very appreciated, even if you think is something obvious :-).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为了确保我理解您的意思:您想要 -
http://mydomain1.com
(端口 80)发出 HTTP 请求 - 然后转到服务器上的端口 8080;http://mydomain2.com
(端口 80)发出 HTTP 请求 - 然后转到服务器上的端口 8081。在 Apache 中实现此目的的唯一合理方法(据我所知)是使用所谓的“反向代理”,解释如下:http://httpd.apache.org/docs/current/mod/mod_proxy.html
简而言之:定义两个基于名称的虚拟主机侦听端口 80,每个反向代理请求到“隐藏”服务器。这两个定义几乎完全相同......这是其中一个的草图,您应该能够得出另一个定义。
上面的定义导致所有 HTTP 请求进入端口 80,在其“服务器路径”标头中包含
mydomain1.com
(这是某人键入包含服务器名称的 URL 时的标准行为;不用担心关于它)或任何提到的别名,被反向代理到localhost:8080
。尝试一下,让我们知道效果如何。祝你好运!
To make sure I understand what you meant: You want -
http://mydomain1.com
(port 80) - then go to port 8080 on your server;http://mydomain2.com
(port 80) - then go to port 8081 on your server.The only reasonable way (that I know of) you can achieve this in Apache is by using what's called a Reverse Proxy, explained here: http://httpd.apache.org/docs/current/mod/mod_proxy.html
In a nutshell: Define two name-based virtual hosts listening on port 80, each reverse-proxying requests to the "hidden" server. The two definitions would be almost exactly the same.... here's a sketch of one of them, you should be able to conclude the other one.
The above definition causes all HTTP requests coming in on port 80, having
mydomain1.com
in their "Server path" header (that's standard behavior when someone types in a URL containing a server name; don't worry about it) or any of the mentioned aliases, to be reverse-proxied tolocalhost:8080
.Try this and let us know how it went. Good luck!