使用 Lighthtpd 为不同子域上的多个应用程序提供服务

发布于 2025-01-08 03:06:01 字数 1163 浏览 1 评论 0原文

我试图为不同的子域提供不同的应用程序,所有应用程序都使用相同的 Lighthtpd 服务器作为前端服务器。所有服务于子域的应用程序也与 Lighthtpd 运行在同一台服务器上。

我已设置 DNS 记录如下(均为 A 记录)

mydomain.com       xx.xx.xx.xx
sub.mydomain.com   xx.xx.xx.xx

xx.xx.xx.xx 对于这两条记录是相同的。

我的Lighttpd配置文件的相关部分如下

$HTTP["host"] =~ "sub.mydomain.com" {
    fastcgi.server = (
        "/ideas.fcgi" => (
            "main" => (
                "host" => "127.0.0.1",
                "port" => "9030",
            )
        ),
    )

    url.rewrite-once = (
        "^(/.*)$" => "/ideas.fcgi$1",
    )
}

$HTTP["host"] =~ "mydomain.com" {
    proxy.balance = "round-robin" proxy.server = ( "/" =>
        ( ( "host" => "127.0.0.1", "port" => 9010 ) ) )
}

在端口9010上运行的进程是一个Java Web应用程序,在9030上运行的进程是一个django webapp作为fcgi进程运行,使用以下命令启动

./manage.py runfcgi method=threaded host=127.0.0.1 port=9030

我的问题是-在我的浏览器中url、mydomain.com 和 sub.mydomain.com 获得相同的 Web 应用程序(该应用程序适用于 mydomain.com)。

sub.mydomain.com 的 Lighttpd 设置似乎被 mydomain.com 的设置忽略或覆盖。我什至尝试反转配置文件中这两个设置的物理位置,但这也没有帮助。

我确信这个配置应该是可能的。我错过了什么吗?

I am trying to serve different subdomains with different applications, all using the same Lighthtpd server as a front server. All applications serving sub-domains are also running on the same server as Lighthtpd.

I have setup DNS records as follows (both are A records)

mydomain.com       xx.xx.xx.xx
sub.mydomain.com   xx.xx.xx.xx

xx.xx.xx.xx is same for both records.

Relevant parts of my Lighttpd configuration file as as follows

$HTTP["host"] =~ "sub.mydomain.com" {
    fastcgi.server = (
        "/ideas.fcgi" => (
            "main" => (
                "host" => "127.0.0.1",
                "port" => "9030",
            )
        ),
    )

    url.rewrite-once = (
        "^(/.*)$" => "/ideas.fcgi$1",
    )
}

$HTTP["host"] =~ "mydomain.com" {
    proxy.balance = "round-robin" proxy.server = ( "/" =>
        ( ( "host" => "127.0.0.1", "port" => 9010 ) ) )
}

The process running on port 9010 is a Java web app and the process running on 9030 is a django webapp running as an fcgi process started with the following command

./manage.py runfcgi method=threaded host=127.0.0.1 port=9030

My problem is - in my browser both the url's, mydomain.com and sub.mydomain.com get the same web application (the app intended for mydomain.com).

It seems that the Lighttpd setting for sub.mydomain.com is either being ignored or overriden by the setting for mydomain.com. I even tried reversing the physical location of both settings in the configuration file, but that did not help either.

I am sure this configuration should be possible. Am I missing something ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

謸气贵蔟 2025-01-15 03:06:01

$HTTP["host"] =~ "mydomain.com" 行正在执行正则表达式匹配,因此它匹配 Django 子域以及域。如果您使用如下字符串等于匹配,则 Django 子域将不匹配。

$HTTP["host"] == "mydomain.com"

可能有更好的方法来做到这一点(例如,一旦匹配第一个虚拟主机,就可以使用命令跳过所有其他虚拟主机),但恐怕我的 lighttpd 知识有限。

The line $HTTP["host"] =~ "mydomain.com" is doing a regular expression match, so it matches the Django subdomain as well as the domain. If you use a string equals match as below, then the Django subdomain will not match.

$HTTP["host"] == "mydomain.com"

There might be a better way to do this (e.g. a command to skip all further virtual hosts once you've matched the first one), but I'm afraid my lighttpd knowledge is limited.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文