B4J Question multiple sites one server

TomDuncan

Active Member
Licensed User
Longtime User
If I have ctd.noip.me and tom.fred.com
Can I serve both these sites from one IP address, one computer and one server.
Sounded like a nice idea.
Can it be done.

Tom
 

Daestrum

Expert
Licensed User
Longtime User
Providing each site connects on a different port it is possible.
 
Upvote 0

TomDuncan

Active Member
Licensed User
Longtime User
But isn't a web site by default mapped to port 80?

Also with noip I have two names both mapped to the same incoming IP address.
I have ctd.noip.me and tomduncan.noip.me

Can I have both of these serving different site layouts. I.e. Different www folders.
 
Upvote 0

Roycefer

Well-Known Member
Licensed User
Longtime User
You can serve up two sites but they'll have to be running in the same server program. In each Handler, you can get the full request URI which will tell you whether your user was navigating to ctd.noip.me or tomduncan.noip.me and then you can decide what content to serve to the user. In this case, you shouldn't give users direct access to statically served pages as they might have ambiguous links.

Another option is to have one server be secure (default port 443) and the other be insecure (default port 80) and then you can have two separate, normal server applications serving up static pages.

You can also specify port numbers in your domain name: ctd.noip.me:1111 and tomduncan.noip.me:2222 and then you could have these go to two separate server programs running on the same computer.
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
It looks like no-ip allows you to redirect port 80 to any port you choose so you could have both running in one server program.
B4X:
...
srvr.Initialize("srvr")
srvr.StaticFilesFolder = "www" ' files for first site
srvr.Port = 51000
srvr.Start
srvr1.Initialize("srvr2")
srvr1.StaticFilesFolder = "www/1" ' files for second site
srvr1.Port = 51001
srvr1.Start
...
 
Upvote 0

TomDuncan

Active Member
Licensed User
Longtime User
Does that mean on my modem I would redirect 51000 and 51001 to port 80

No I am missing something here.
How will it know to go to which port.
Or www or www/1
 
Last edited:
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
As Erel recommended it's better to have two servers running, if the app crashes it only takes one site off-line not both.
 
Upvote 0
Top