Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure Apache WebServer to be accessed by public domain (or static IP) I have?

I am trying to setup a web-server at home on PC.

I have an Static IP address (say 1.2.3.4 or Domain XYZ[dot]com), which I have configured on my router. When I try to access, XYZ[dot]com or "1.2.3.4", it opens my routers login page.

On the other hand, Apache Server, installed on the PC, works fine. when I write localhost/index.html or 127.0.0.1/index.html - it opens that page.

QUESTION

  • How can I link the Public IP address to the Apache Server (or the website hosted on localhost on my PC)?

EXPECTED SOLUTION

  • If anyone visits "http://XYZ[dot]com", the website hosted on my PC is opened on his/her web browser.
like image 328
wafers Avatar asked Mar 29 '14 11:03

wafers


1 Answers

The router's login page is usually accessed via a private IP. The router's admin interface shouldn't be made available to the Public Internet.

What you need to do is:

  • find out what your router's public IP is (you can use http://whatismyipaddress.com/)
  • setup port forwarding on your router. You want connections made to the routers public IP to be forwarded to your PC. Ex: Your router's public IP is 21.21.21.21 and your PC's private IP is 192.168.0.100. You need to configure a rule which says that any connection made to to 21.21.21.21:80 needs to be forwarded to 192.168.0.100:80

As for the http://XYZ[dot]com part you need to setup that domain pointing to your public IP with a com. DNS registrar and configure an apache virtual host for that domain (http://httpd.apache.org/docs/2.2/vhosts/)

like image 187
Ioan Alexandru Cucu Avatar answered Sep 19 '22 12:09

Ioan Alexandru Cucu