Manage different services on the same port with multiple instances of DietPi Topic is solved

Suggestions for features and software you would like to see in DietPi, goes here.
Post Reply
Gigabit
Posts: 27
Joined: Fri Dec 23, 2016 6:28 pm

Manage different services on the same port with multiple instances of DietPi

Post by Gigabit »

There comes a point when one loves SBCs that one becomes two board computers running DietPi on a single network. It allows you to divvy up different services to different devices based on use case. Managing this is not an issue as long as no other service utilizes the same port on two different devices. It becomes complicated when you have services that require 443/80 or other common ports.
User avatar
Joulinar
Posts: 2277
Joined: Sat Nov 16, 2019 12:49 am

Re: Manage different services on the same port with multiple instances of DietPi

Post by Joulinar »

Hi,

honestly I don't understand your issue fully.

If you have more than one device, you could have port 80 used on each of them without problem. Each device can host a web server LISTEN on port 80.

However on a single device, port 80 can be used only once. Multiple web server would ne to be separated by deifferent ports.

But this has nothing to-do with DietPi. This is valid for every system/OS.
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
Gigabit
Posts: 27
Joined: Fri Dec 23, 2016 6:28 pm

Re: Manage different services on the same port with multiple instances of DietPi

Post by Gigabit »

I may have misunderstood initially. I know this is not specific to DietPi. How does this work with the domain name then with two devices?
When port forwarding and set up It can only go to one device per port, correct?
User avatar
Joulinar
Posts: 2277
Joined: Sat Nov 16, 2019 12:49 am

Re: Manage different services on the same port with multiple instances of DietPi

Post by Joulinar »

yes that's a general limitation. However there are solutions available. Easiest one would be running a revers proxy. Your entire traffic on port 80 will be forwarded by your router to the revers proxy. You could configure the revers proxy that way, that it will forward the http request depending on your url/patch. An example

Code: Select all

https://myDomain.com/application1 > forward to http://192.168.0.20:80
https://myDomain.com/application2 > forward to http://localhost:8080
https://myDomain.com/application3 > forward to http://192.168.0.31:4711
There are some advantages on this.
  1. SSL termination will be done on the revers proxy. You just need 1 certificate for 3 applications. However communication inside your local network will be http only. But yeah it's your local network :)
  2. You just need to open port 80 + 443 on your router and you will be able to reach all kind of application. Even if they are not running on 80/443
  3. Easy way to include more applications to be reachable from the web
A good choice for a revers proxy could be Nginx https://docs.nginx.com/nginx/admin-guid ... rse-proxy/

Another more complicated solution could be using HaProxy viewtopic.php?p=25447#p25447
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
Gigabit
Posts: 27
Joined: Fri Dec 23, 2016 6:28 pm

Re: Manage different services on the same port with multiple instances of DietPi

Post by Gigabit »

Would it make sense for DietPi to set up web services as behind SSL termination web proxy by default? Then with the helper script to add additions (pointing to other devices) or configure ports.

The concern is that when updating, adding/removing applications that user custom configurations for the web server would break.
User avatar
Joulinar
Posts: 2277
Joined: Sat Nov 16, 2019 12:49 am

Re: Manage different services on the same port with multiple instances of DietPi

Post by Joulinar »

personally I don't think it's a good idea to set up reverse proxy by default. This would force everybody to use a proxy even if not needed. Not everybody needs internet access for it's web applications. As well it's removing flexibility to go with the solution of your choice as it will lock you on a specific scenario.
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
Gigabit
Posts: 27
Joined: Fri Dec 23, 2016 6:28 pm

Re: Manage different services on the same port with multiple instances of DietPi

Post by Gigabit »

That's a very recent perspective. Are my concerns valid especially with Dietpi update?
User avatar
Joulinar
Posts: 2277
Joined: Sat Nov 16, 2019 12:49 am

Re: Manage different services on the same port with multiple instances of DietPi

Post by Joulinar »

Not sure if I understood your last question. What you do mean be this?
Are my concerns valid especially with Dietpi update?
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
Gigabit
Posts: 27
Joined: Fri Dec 23, 2016 6:28 pm

Re: Manage different services on the same port with multiple instances of DietPi

Post by Gigabit »

My concern is if I set up a reverse proxy and Dietpi updates itself or an application updates/added that it could break the custom configuration for the reverse proxy. Obviously it'll have to be updated for new additions or removals manually for particular programs. However I could envision updating a program/removing and it breaking the entire system where the Web server goes off-line.
User avatar
Joulinar
Posts: 2277
Joined: Sat Nov 16, 2019 12:49 am

Re: Manage different services on the same port with multiple instances of DietPi

Post by Joulinar »

that's why it's recommended to perform dietpi-backup before doing any updates ;)

Anyway, dietpi-update should have limited impact on custom config files
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
Post Reply