url - 如何将 URL 映射到端口和修改后的 URL?

标签 url nginx port lighttpd forwarding

如何将 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'”

最佳答案

使用 Nginx 很容易完成:

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

关于url - 如何将 URL 映射到端口和修改后的 URL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22635019/

相关文章:

java - Google 索引页是否从 Servlet 返回?

http - URL:带@的用户名

nginx - Go Revel 框架端口 9000 已被占用

ruby-on-rails - NGINX 下载慢,以 send_file 启动

url - 如何删除 :port number from the end of an IIS URL?

ubuntu - 当我在 cgi 中运行和回显 lsof 时没有显示输出 - Ubuntu

google-chrome - URL 嵌入凭证

java - 通过在 java 中编码获取 URL 响应

nginx 别名+位置指令

Docker 覆盖网络仅发布一些列出的端口