【问题标题】:Forwarding from subdomain to port not working从子域转发到端口不起作用
【发布时间】:2013-07-10 12:37:45
【问题描述】:

问题:

我正在运行 Windows Vserver,并且在此服务器上我正在端口 8081 上运行独立的 Grails 应用程序,这意味着当我打开时

localhost:8081 (local)domain:8081

在浏览器中,我看到了 Grails 应用程序的界面。

我正在寻找的是一种输入方式

subdomain.domain

转发给我

domain:port

我已经读到这可以使用 Apache 上的虚拟主机来完成。我使用了 XAMPP Apache,因为无论如何我都在运行 XAMPP MySQL。 我将这一行添加到 WIndows 主机文件中:

127.0.0.1 subdomain.domain

这部分到 apache/conf/extra/httpd-vhosts.conf:

<VirtualHost  *:80>
    ServerName http://localhost
    DocumentRoot "C:/xampp/htdocs"
</VirtualHost>

<VirtualHost *:80>
    ServerName http://subdomain.localhost
    Redirect / http://localhost:8081
</VirtualHost>

我的预期:

  • 当我打开 domain 时,我看到了 xampp 管理界面

  • 当我打开 subdomain.domain 时,我看到 Grails 应用程序(domain:port

会发生什么:

  • 不管我打开domainsubdomain.domain我总是转发到domain:port

我做错了什么?

问候 H

【问题讨论】:

  • 请看这篇,我想对你有帮助:stackoverflow.com/questions/17154711/…
  • 谢谢,但没有帮助。请注意,我不是在寻找通配符子域,而是在寻找 a) 一个特定子域和 b) 没有子域的组合。
  • 您只能为特定的子域指定通配符。

标签: apache subdomain portforwarding


【解决方案1】:

解决方案(不知道技术差异在哪里):

<VirtualHost Server-IP:80>
    ServerName http://domain
    DocumentRoot "C:/xampp/htdocs"
</VirtualHost>

<VirtualHost Server-IP:80>
    ServerName http://subdomain.domain
    Redirect / http://domain:port
</VirtualHost>

我什至不必在 Windows 主机文件中输入任何条目。 NameVirtualHost 也没有必要。

【讨论】:

    猜你喜欢
    • 2012-08-07
    • 2014-08-30
    • 1970-01-01
    • 2015-04-26
    • 1970-01-01
    • 2017-01-24
    • 1970-01-01
    • 2021-06-12
    • 2012-02-20
    相关资源
    最近更新 更多