Return to Level1Techs.com

How to make custom subdomains with openwrt router


#1

in advance i apologize for my ignorance of networking, i am very new to it.
my situation:
i have an openwrt router with many DHCP clients behind it. the router itself is a DHCP client to my ISP.
for the sake of the argument lets say i own the domain “example.com”.
i have redirected the @ option in my domain name provider to the DHCP address provided to my router by my ISP.
i have an http server, that with my port forwarded, people outside my house can connect to it using “example.com:80”.

my question:
i want to have 2 different http servers in my house, both on port 80, and on different machines. lets name these machines comp1 and comp2 for arguments sake. how can i make my own subdomains to where these servers can be accessed externally via “comp1.example.com:80” and “comp2.example.com:80”?
in other words, i want to use subdomains in the same way i’d use ports so that other people have to specify in a different subdomain for each of my services instead of a different port.
if such a thing is even possible.


#2

Did you buy a router with openwrt on it, or did you flash it yourself? And what version are you using? And router make/model?


#3

Yes this is possible, install nginx on your router and do name-based virtual host reverse proxying with proxy_pass and proxy_set_header.


#4

i flashed my TP-LINK ARCHER C7


#5

would that work for any service? or just http?


#6

It does technically support protocols other than http/https but they aren’t arbitrary ones like your minecraft server, they’re memcached, fastCGI, etc. For those just setup normal port forwards.