Can I (DNS) map one subdomain to multiple entry points in the Play Framework

Is the scenario possible below? The warning is that I understand DNS only in its basic form.

We have an API (built using Play ) that we would like to make available through the address: http://api.publicname.com

However, we would like to split this API into 2 Play projects (e.g. myapione and myapitwo). Then access them with only one domain, but two separate "subfolders"

So, I was looking for a match option ...

http: //myinternal.domain: 9000 at http://api.publicname.com/myapione

... and more Play application

http: //myinternal.domain: 9001 at http://api.publicname.com/myapitwo p>

The end result we are looking for is something like below. Our calls would look like ...

http: //myinternal.domain: 9000 / products / 123 also http://api.publicname.com/myapione/products/123

http: //myinternal.domain: 9001 / orders / 456 also http://api.publicname.com/myapitwo/orders/456

0
source share
2 answers

Purpose:

Public URL              -> maps to -> internal URL
http://api.publicname.com/myapione -> http://localhost:9000
http://api.publicname.com/myapitwo -> http://localhost:9001

, @applicius, HTTP- " " "", "" "" HTTP-. .

Nginx, Apache .. . , nginx . , , Zeus ZXTM. , , , - .

nginx , - :

server {
    listen       80;
    server_name  api.publicname.com/myapione;

    location /myapione {
        proxy_pass        http://localhost:9000;
        proxy_set_header  X-Real-IP  $remote_addr;
    }

    location /myapitwo {
        proxy_pass        http://localhost:9001;
        proxy_set_header  X-Real-IP  $remote_addr;
    }
}

"" , , . , static HTML- , /:

    location /static/ {
        alias /app/myapp-pages/static;
    }

    location / {
        proxy_pass        http://localhost:8000;
        proxy_set_header  X-Real-IP  $remote_addr;
    }

:

Public URL              -> maps to -> internal URL
http://api.publicname.com/myapione -> http://localhost:9000
http://api.publicname.com/myapitwo -> http://localhost:9001
http://api.publicname.com/static   -> local file assets
http://api.publicname.com/...      -> http://localhost:8000

, : , , nginx.

ZXTM , , . ( , - , , , , .)

, Play, , API , HTTP-. HTTP- , DropWizard, API .

+1

Play virtualhost. , HTTP: Apache, Nginx, Varnish

, Nginx:

server {
  listen: 80
  server_name main.virtual.host alias.virtual.host;

  proxy_pass http://localhost:3000;
}
+1

All Articles