I have a 3b+ that I want to run several services on to support my home network. All of the services provide web interfaces to manage the service. I can handle remapping the ports on the ones that overlap (most are in docker containers). What I am having trouble with is I want to define DNS records for the individual services, and have those records redirect to the appropriate ports. The best I am coming up with is to add an extra service to listen on 80 (nginx?), and redirect based on host. Is there a simpler way to accomplish this?

Pi with Static IP
Service 1 listening on Port 81
Service 2 listening on Port 82
Service 3 listening on Port 83

Router DNS table:
Srvc1.home.domain -
Srvc2.home.domain -
Srvc3.home.domain -

Browser Action:
Srvc1.home.domain -> -> something? -> port 81
Srvc2.home.domain -> -> something? -> port 82
Srvc3.home.domain -> -> something? -> port 83

  • This has nothing to do with Raspberry Pi. If you want to use DNS to locate your services you should add SRV records to your (local?) DNS server. For example here is the query for my LDAP service: dig +noall +answer SRV _ldap._tcp.example.com, and the answer _ldap._tcp.example.com. 38400 IN SRV 0 0 389 myserver.example.com.. That means, the ldap service is located at myserver on port 389.
    – Ingo
    Commented Jun 5, 2020 at 17:40
  • @Ingo near as I can tell my routers DNS proxy doesn't allow me to inject srv records, just A records. So this approach would involve setting up a full fledged DNS server, which on my network would also land on the same Pi. Also I didn't think srv records supported http, much less multiple http instances on the same host? Or am I missing something in your suggestion?
    – Rozwel
    Commented Jun 5, 2020 at 18:18
  • As already noted, due to our policies the question is out of scope here and comments are not suitable for discussions. i would need some more details about your network environment. I suggest to ask at serverfault.com :)
    – Ingo
    Commented Jun 5, 2020 at 18:41

2 Answers 2


depending on what kind of router you have, you can do port forwarding there too.

You'd forward port 80 on Srvc1.home.domain to 81 on your server, 80 on Srvc2 to 82 on your server etc. It might look a little cluttered but your Srvc1/2/3 hosts don't even need to exist. It works the same as port forwarding from "the internet" through a natted router (a router that most use at home).


  • Does not appear to be an option for mine. I can set up DNS entries to route host names to IPs, and I can set up port forwarding between IPs, but I have not seen anything to let me do port forwarding by host name.
    – Rozwel
    Commented Jun 5, 2020 at 12:53
  • Something else you could easily do, omitting port forwarding on the/a router, is make the/a machine multi homed, with virtual interfaces or so. That is easy to do, especially if you're running linux. If what you do is all web based, you can also set up virtual hosts within apache. however, without port forwarding you cannot (on a router) direct traffic to a specific port unless you're doing NAT internally. Since your router doesn't do that, I doubt you can define nat interfaces on your router either. Soeasiest would probably be virtual interfaces or virtual hosts in apache
    – Ron
    Commented Jun 5, 2020 at 18:06

Using nginx, you can create multiple "servers" which listen on the same port, but differentiatetd based of the domain name used (specified in the http host header by the client) by specifying the servernane in nginx. You would then have nginx do a proxy pass which will forward the request off to the app. If you use Apache, you can do something similar.

That of course assumes that you are using an http based app. If not, you can either assign multiple IP's to your pi and have your app bind to a certain IP, or use DNS srv recorders if your app supports it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.