B4J Question WebApp on port 80?

u2005k

Member
Licensed User
Longtime User
Hi
If I build webapp and deploy with domain, it will be difficult for people to include other than port 80.
Can I deploy webapp associated with some domain name and on port 80 so that user need not enter custom port number in url? Also many times companies don't like to open ports other than standard ports on their firewall.

Does it also support SSL?


Uday
 

Roycefer

Well-Known Member
Licensed User
Longtime User
Port 80 is the default for HTTP. If you want to use the default port for HTTPS (to use SSL, for example), use port 443. And yes, you can deploy a web-app using any port you like. Also, if you have some port-forwarding mechanism upstream of your server (like a router, for example), you can forward incoming port 80 traffic to any port you wish on your server.

B4J web-apps support SSL.
 
Upvote 0

u2005k

Member
Licensed User
Longtime User
Hi Roy,
Thanks a lot. Now I am able to run test WebApp on server, btw it takes default port 8080. If I set
srvr.port = 80 then it works without specifying port number in the url.

This is great, is it possible that multiple webapps run on the single port (80)? e.g. In Apache one can create virtual hosts or I can have multiple PHP applications stored in different directories.

e.g. www.mydomain.com -> serves first webapp
www.mydomain.com/secondapp -> serves second webapp



Thanks & regards...
Uday
 
Upvote 0

Roycefer

Well-Known Member
Licensed User
Longtime User
In the domain name scheme you used, www.mydomain.com would serve a visitor your server's index.html page (unless you had a filter set to redirect them to a login page or something). www.mydomain.com/secondapp would send them to a WebSocket or a Handler called "secondapp". This will be written in the same server program. The code would look something like this:
B4X:
Dim srvr as Server
srvr.Initialize("srvr")
srvr.Port = 80
srvr.AddHandler("secondapp", "secondapp", False)    'Now, create a new Handler Class in the IDE and write your "secondapp" logic in there
srvr.AddWebSocket("WS1", "WS1")                        'Now create a new WebSocket Class in the IDE

If a visitor visited www.mydomain.com, they would see your index.html page. If they visited www.mydomain.com/secondapp, their GET request would be handled by the "secondapp" Handler you created. If they visited www.mydomain.com/WS1, their browser would be connected to a WebSocket handled by the WS1 class you created running on the server. I recommend you read one of the many tutorials on B4J server Erel has provided. They are quite easy to follow and well worth the time.
 
Upvote 0
Top