B4J Question Question about WebApps and Jetty.

amykonio

Active Member
Licensed User
Longtime User
Hi.

Last month I was doing some tests with B4J and webapps. I found it powerful and easy to use. But I do have some questions.
B4J webapps do have a jetty server embedded.

1) If we want to run more than one webapps on the same machine, we have to set each instance to use a different port. I believe there is no other way to achieve that. Am I right?
2) If we want the outside world to reach those applications using strictly port 80 or 443 and without redirection, we should have a separate public ip for each instance and configure NAT to internally translate public ip1 port 80 to internal ip instance 1 port xx1 and public ip2 port 80 to internal ip instance 2 port xx2. Am I right?

If scenario (2) is working, this isn’t a recommended solution, because it may require many public ip’s. Is there another way to solve that “issue”?
Finally, it would be nice if we had a way to somehow deploy a webapp to Jetty and not have it embedded in our app. Don’t know if this could be possible, I understand it’s not supported.

Andreas.
 
Solution

alwaysbusy

Expert
Licensed User
Longtime User
Upvote 1
Solution

amykonio

Active Member
Licensed User
Longtime User
The easiest way around it is is using something like HAProxy before it. Everything arrives at the same ip (or domain) on port 80/443 and HAProxy will then pass it through to e.g. localhost:51042 or localhost:512 depending on its settings. We for example use two aliases https://work.one-two.com which points to localhost:51042 and https://api.one-two.com which points to localhost:55055.

Some HAProxy examples: https://seanmcgary.com/posts/haproxy---route-by-domain-name

Alwaysbusy
Thank you for your answer.
I will take a look at HAProxy.

By the way https://api.one-two.com response from jetty is: not found.
And you are doing a great jobs with your frameworks.

Andreas.
 
Upvote 0

hatzisn

Well-Known Member
Licensed User
Longtime User
Also nginx can act as a reverse proxy. I have followed some tutorials on YouTube and I find it quiet ease to use. I use it in Raspberry Pi.
 
Upvote 1

Pendrush

Well-Known Member
Licensed User
Longtime User
I'm using nginx as reverse proxy/cache server in production last 6-7 months with 2M daily opened pages, with 8 CPU, 16GB ram, wIth certbot (for https cert), and I'm thrilled with how fast it works. CPU is constantly below 30%, max ram usage about 4-5GB.
 
Upvote 1
Top