LAN web servers as WAN subdomains

Hi,

I have:

  • fixed public IP address,
  • registered private domain f.ex.: sample.my,
  • some web servers/services on LAN f.ex. raspian1(162.168.1.101) and raspian2(162.168.1.102).
    What I want is:
  • reach my local web services from WAN by calling them rsp1.sample.my and rsp2.sample.my

Is it possible to achieve functionality described above?
If yes - are there any samples/links?
Or what keywords should I search/study for?

Thanks in advance.

Would be easier if you separated them by using different ports.

sample.my:1234 -> rsp1
sample.my:4321 -> rsp2

Ah, that I know :slight_smile:
That's easy by using port forwarding, but I would like to use subdomains.

You will need to use a reverse proxy to do this. The actual (sub) domain names do not factor into routing decisions if you only have a single public ipv4 address. The router doesn’t see any information about the domain/subdomain request, only that packets have arrived on the interface with a certain destination port.

A web server with reverse proxy configured, however, can see that the http/https requests do contain subdomain requests. From that, a reverse proxy can appropriately redirect the packets to the desired server.

3 Likes

I would recommend NGINX.

https://superuser.com/questions/1266826/openwrt-redirect-incoming-wan-traffic-based-on-domain-name

3 Likes

Thanks @pavelgl - these links helped for start.

I successfully installed nginx and configured it, by using this advice:

It is working very well from LAN, but not from WAN (Unable to connect).
Now I am no stuck on this.
Which parts of openwrt configs could I check?

Check if your ISP actually allows the connection, try telnet to the port you're using (80 or 443 ?).

1 Like

My ISP allows it.
Before installed nginx I used port forwarding. Now those port forwarding configs are disabled.

You need to modify the firewall to accept connections to the corresponding port from the wan side.

1 Like

Ah, my blind! Of course.
All is working as expected.
Thank you for your support!

Or run haproxy directly on the router. I am running several domain names as well as ssh on the same 443 port.

1 Like

I am using nginx directly on the router too..
But it could be interesting to look on a "how to"...