Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to map URL to port and modified URL?

How do I map www.somesite.com/api(.*) to www.somesite.com/$1:9000? (I need to map /api to Play framework application running @ port 9000)

I did the following:

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

This gets me to somesite.com/api:9000 when I go to somesite.com/api, and I get "Action not found: For request 'GET /api'"

like image 410
Alexander Avatar asked Sep 18 '25 00:09

Alexander


1 Answers

It is easily accomplished using Nginx:

    location /api/ {
            rewrite   ^/api(/.*)$ $1 break;
            proxy_pass http://localhost:9000;
    }
like image 84
Alexander Avatar answered Sep 19 '25 15:09

Alexander