Hello all,
I have the NAS with Open Media Vault and Nextcloud in my local network (192.168.1.20). Nextcloud is using ports 444 for https and 81 for http. In order to access nextcloud from the internet I got domain (domain.name), add my external IP to public DNS, configured port forwarding on OpenWRT from WAN 80 => 192.168.1.20:81 and WAN 443 => 192.168.1.20:444. It works both from the internet and my local network.
In order to make transfers faster in case of using my local network I want to route all local traffic from domain.name to 192.168.1.20. Is there any way to route all traffic from my LAN with destination "https://domain.name(:443)" to "https://192.168.1.20:444"?
I tried to add to /etc/hosts line with "domain.name 192.168.1.20". Currently it works only if I specify port in the browser like "https://domain.name:444/nextcloud/apps/files/", but this is not a desirable behavior.
Also I tried to make rules for LAN to LAN port forwarding:
uci add firewall redirect # =cfg113837
uci set firewall.@redirect[-1].dest_port='444'
uci set firewall.@redirect[-1].src='lan'
uci set firewall.@redirect[-1].name='nextcloud_local'
uci set firewall.@redirect[-1].src_dip='192.168.1.20'
uci set firewall.@redirect[-1].src_dport='443'
uci set firewall.@redirect[-1].dest_ip='192.168.1.20'
uci set firewall.@redirect[-1].dest_port='444'
uci set firewall.@redirect[-1].dest='lan'
uci set firewall.@redirect[-1].target='DNAT'
So this is my question - how to do port forwarding inside LAN? I showed my configuration for the port forwarding in the initial message and it doesn't work
If both devices are in the same lan (192.168.1.X) then they can communicate directly without passing traffic through OpenWrt.
If you need to enforce some policies, you'll need to either do it on the web server or move the server to a different firewall zone.
What @anon45274024 says is technically possible, but it requires a web server on the router which is capable to rewrite and redirect the packets. For example.