【问题标题】:How to map URL to port and modified URL?如何将 URL 映射到端口和修改后的 URL?
【发布时间】:2014-03-25 12:43:38
【问题描述】:

如何将 www.somesite.com/api(.*) 映射到 www.somesite.com/$1:9000? (我需要将 /api 映射到运行 @ 端口 9000 的 Play 框架应用程序)

我做了以下事情:

$HTTP["url"] =~ "^/api" {
    proxy.server = ( "" =>
    ( ( "host" => "127.0.0.1", "port" => 9000 ) ) )
}

当我访问 somesite.com/api 时,这会将我带到 somesite.com/api:9000,并且我得到“找不到操作:对于请求 'GET /api'”

【问题讨论】:

    标签: url nginx port lighttpd forwarding


    【解决方案1】:

    使用 Nginx 很容易实现:

        location /api/ {
                rewrite   ^/api(/.*)$ $1 break;
                proxy_pass http://localhost:9000;
        }
    

    【讨论】:

    • 这不是完整的解决方案,它不会在 ubuntu 上运行。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-10-22
    • 2020-03-14
    • 1970-01-01
    • 2011-06-02
    • 1970-01-01
    • 1970-01-01
    • 2016-08-08
    相关资源
    最近更新 更多