0

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

1 Answer 1

2

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
8
  • could you tell more about 'fix local address on server aka 192.168.x.x'. because my server listens only to name-based request that I register in /etc/apache2/sites-available and to 127.x.x.x (which are synonyms of localhost), but when I, say, telnet 192.168.x.x 80, then the request doesn't seem to be resolved by apache.
    – nakajuice
    Apr 2, 2014 at 11:41
  • In apache you can set to appache to respond to one address or more. in sudo gedit /etc/apache2/apache2.conf you have Listen 80. That mean accept connection on port 80. After that you must set VirtualHost. If you config begin with <VirtualHost *:80> and all other after / This mean that site is accessible for all ip addresses. On server with 2 nic card with 2 different ip addresses you can configure <VirtualHost xxx.xxx.xxx.xxx:80> where xxx.xxx.xxx.xxx represent ip from one nic card ....
    – 2707974
    Apr 2, 2014 at 11:50
  • No you don't telnet to localhost on port 80. Telnet to yourdomain.com on port 80. If you have only one site probably will work and telnet localhost 80
    – 2707974
    Apr 2, 2014 at 11:51
  • I got Listen 80 in ports.conf. But setting <VirtualHost *:80> or more specifically <VirtualHost 192.168.x.x:80> doesn't bring anything, my 192.168.x.x request are still being timed out. As if 192.168.x.x request weren't local. By the way, I accidentally found a solution, since 192.168.0.101 works fine. The only mention of this address in my router settings is Assigned IP in DHCP client, but these entries are not editable
    – nakajuice
    Apr 2, 2014 at 12:04
  • I think the solution would be setting correct routing. See my ip route output in edit.
    – nakajuice
    Apr 2, 2014 at 12:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .