B4J Question [B4J] Run two(Or More) server in a VPS

jinyistudio

Well-Known Member
Licensed User
Longtime User
Hi

How to(Or Could I) setting Multi-domain name for every APP when i running two or more B4J-APP in same VPS ?

Eaxmple:
a.com -> 192.168.1.1:8000 (APP1)
b.com -> 192.168.1.1:8001 (APP2)
 

jinyistudio

Well-Known Member
Licensed User
Longtime User
Hi

With Nginx as websocket proxy !
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
This might be thé stupidiest suggestion ever, but, why not create a b4j server to receive thé "général" call and make it calk thé URL spécific page? À kind of "transparent redirect"
 
Upvote 0

billzhan

Active Member
Licensed User
Longtime User
For ws, you need to set header "Upgrade" and "Connection". https://www.nginx.com/blog/websocket-nginx/

Config below may work.
B4X:
### $ cat /etc/nginx/nginx.conf

worker_processes  1;

events {
    worker_connections  1024;
}

http {
    # include       mime.types;
    # default_type  application/octet-stream;
    # sendfile        on;
    # keepalive_timeout  65;

    server {
        listen      80;
        server_name a.com;
        location / {
            proxy_set_header   X-Real-IP $remote_addr;
            proxy_set_header   Host      $http_host;
           
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
           
            proxy_pass         http://127.0.0.1:8081;
        }
     
    }

    server {
        listen       80;
        server_name b.com;
        location / {
            proxy_set_header   X-Real-IP $remote_addr;
            proxy_set_header   Host      $http_host;
           
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
           
            proxy_pass         http://127.0.0.1:8082;
        }
       
    }
}
 
Upvote 0

jinyistudio

Well-Known Member
Licensed User
Longtime User
Hi

B4X:
server {
        listen      80;
        server_name vps.jinyistudio.tw;
        location / {
            proxy_set_header   X-Real-IP $remote_addr;
            proxy_set_header   Host      $http_host;
       
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
       
            proxy_pass         http://127.0.0.1:8001;
        }
 
    }


I try your conf in VPS. It's OK.

As following, vps.jinyistudio.tw isn't OK but vps.jinyistudio.tw:8001 is OK when i connect from remote desktop .




 
Last edited:
Upvote 0

jinyistudio

Well-Known Member
Licensed User
Longtime User
Hi

I try vps.jinyistudio.tw work fine in other PC ! Why ????
 
Upvote 0

billzhan

Active Member
Licensed User
Longtime User
May be the old contents are cached in your browser. Try to reload the page (google chrome / firefox Ctrl+F5) .

Or use browsers
 
Upvote 0

jinyistudio

Well-Known Member
Licensed User
Longtime User
press "Ctrl+F5 " work fine !
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…