Ubuntu: Forward HTTP requests to local Apache server behind router?



Question:

I have an Apache server running on Ubuntu, and by default it is using name-based virtual hosts. For some reason I have to make my local server publicly accessible, but the problem is that I am running internet with WLAN router, and my WLAN router allows IP forwarding only to local IP addresses (not name-based hosts), so I can't forward HTTP request to my external IP address to e.g. localhost, but I can forward to, say, 192.168.x.x.

So my question is, can I make my Apache server run on some 192.168.x.x address to make it possible for router to forward HTTP requests to my local server.

Sorry for my amateur naive language, I am quite new to networking and stuff.

Thanks in advance!

EDIT

ip route output:

default via 192.168.0.1 dev wlan0 proto static 192.168.0.0/24 dev wlan0 proto kernel scope link src 192.168.0.101 metric 9


Solution:1

You can. Apache server represent himself with ip address from nic card. If you configure apache server to listen on port 80. Also to do port fw you must have:

  • fix public ip address on wan side of router or ddns record for non fix public address
  • fix local address on server aka 192.168.x.x
  • do port fw on router from wan to lan for traffic on port 80
  • check firewall, must allow traffic to port 80

If you have you domain you can make A record on dns server

yourdomain.com      A   your_public_ip_address  

When some wish to see you site traffic flow will go on this way:

  • enter a yourdomain.com in browser
  • pc ask dns to resolve logical name to ip address
  • pc send http req to ip address
  • request travel via internet to your wan interface on router
  • router pick traffic and forward to local ip, based on your rule
  • server got http req on nic card
  • server send answer to requester on same route

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »