Domain redirection at the router level

Hi,
I have a domain and subdomain.
Is it possible to redirect domain at router level?

I want to get something like this:

domain.com -> 192.168.1.131

sub.domain.com -> 192.168.1.119

Is it possible? :slight_smile:

You can go to the hostname section in Luci, under Network. You may also modify /etc/hosts directly.
Of course this is only going to work if your device uses the ip of the router as DNS server (this is the default option).

That's not what I mean :confused:
I want to get something like vhost in apache

<VirtualHost *:443>
    ServerAdmin webmaster@localhost
    ServerAlias   www.xxx.xxx.tk
    ServerName xxx.xxx.tk

    ProxyRequests Off

    <Proxy *>
            Order deny,allow
            Allow from all
    </Proxy>
    ProxyPreserveHost on
    ProxyPass / http://192.168.1.119/
</VirtualHost>

Ah, sorry, I don't know how to help you then!

Use nginx as reverse proxy.

Thanks for the answers :slight_smile:

I don't have enough memory on the router :confused:

Free space: 65% ( 380.00 KB )

Is there something lighter in weight?

Can you maybe just add entries to the router's /etc/hosts file?

192.168.1.131 domain.com
192.168.1.119 sub.domain.com

You'd need to restart the dns server (dnsmasq I guess), but afterwards it should start handing out the local IPs:

PING domain.com (192.168.1.131) 56(84) bytes of data.
From 192.168.1.2 (192.168.1.2) icmp_seq=1 Destination Host Unreachable

PING sub.domain.com (192.168.1.119) 56(84) bytes of data.
From 192.168.1.2 (192.168.1.2) icmp_seq=1 Destination Host Unreachable

Obviously anything else will go the these IPs as well when using the domain names, ping etc., instead of just port 80. But if you don't care about that maybe this is fine.

I think the idea is he wants people on the internet to connect to an http daemon on his router but when they request a certain domain name, that request is forwarded to a particular machine on the LAN based on the domain name... so basically a reverse proxy. And he wants it in less than 380kB :rofl:

@twitchthis it's going to be hard to get something lighter in weight than nginx, the nginx binary is pretty close to that size depending on architecture, but it's tight. How about run it on a different device?