This is not the purpose of a router, routers w/NAT operate at Layer 3 and Layer 4 (IP and Port) what you need operates at layer 7 (application: http).
TLDR; You need to configure a web proxy to route traffic based on HOST headers, which should be a redundant set of systems like haproxy/keepalived or nginx. Which there are MANY Q/A's here on how to do this.
mod_proxy Fowarding Based on Request Host Header
All that said, if you needed to install nginx on your router you could.
opkg update
opkg install nginx
/etc/nginx/nginx.conf
server {
server_name site1.example.com;
location / {
# app1 reverse proxy
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://192.168.1.3:80;
}
access_log /var/log/nginx/site1.example.com_access.log;
error_log /var/log/nginx/site1.example.com_error.log;
}
server {
server_name site1.mydomain.com;
location / {
# app2 reverse proxy
proxy_pass http://192.168.1.4:80;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
access_log /var/log/nginx/site1.mydomain.com_access.log;
error_log /var/log/nginx/site1.mydomain.com_error.log;
}
Where 192.168.1.3 and 192.168.1.4 are your backends.
https://wiki.openwrt.org/doc/howto/http.nginx
Is it possible to do it using squid? – user2513149 – 2017-11-08T20:03:06.480
Technically yes but squid is a forward proxy by design – Jacob Evans – 2017-11-08T20:20:10.083
And what about the
uhttpd
server that comes by default with OpenWRT? – user2513149 – 2017-11-09T04:28:17.073No experience with that, maybe open a new thread specific to uhttpd and openwrt in super user exchange, this is for business systems. – Jacob Evans – 2017-11-09T05:06:29.680