How to access website hosted in localhost from internet

Web programming topics

How to access website hosted in localhost from internet

Postby Neo » Tue Mar 23, 2010 5:57 am

Following steps will allow you to access a website hosted on your machine (localhost) from internet (no matter you have a ADSL modem that brings you a dynamic WAN IP).

  1. Assign a static IP to your computer (with web server)
    Each computer in a network has its own internal IP address. That IP address may be static, which means that it never changes. Or, as is likely if you share an Internet connection with other computers, the internal IP address may be assigned dynamically and may change from time to time.

    Note: in a network configuration, the internal IP is not the same as the IP assigned by your ISP. The IP assigned by your ISP can be either static or dynamic.

    When you are opening ports to allow incoming connections to your computer, your computer must be assigned a static internal IP address, to ensure that the incoming connections always go to the correct computer.

    There are several steps:
    1. See your current IP address
      Find your current IP address and whether it is static or dynamic:

      1. Open Windows Start menu
      2. Select Run. Type: command and click OK.
      3. At the blinking cursor, type: ipconfig /all and press Enter.
      4. Look for these entries near the end of the list:
        • Dhcp Enabled. No means your IP address is static. Yes means it is dynamic.
        • IP Address. This is your current IP address.
      5. To exit, at the blinking cursor, type: exit and press Enter.

      If your current IP address is:
      • Static, then make note of the IP address. You need the IP address when you open ports in your router or firewall.
      • Dynamic, then assign a static IP address instead.

      ipconfig.gif
      ipconfig.gif (17.34 KiB) Viewed 14511 times


    2. Choose a static IP address
      Choose an IP address, and collect other information needed in order to assign a static IP address to your computer.

      1. In your router administration program, find and remember this information:
        • Router (Gateway) IP address
        • Subnet Mask
        • IP addresses of your DNS servers
      2. In your router administration program, find an IP address that can be assigned as a static IP. The address:
        • Must not be one that might be assigned to someone as a dynamic address.
        • Must not be one that has been assigned to another device (often these are the low numbers).
        • Must be lower than the range of dynamic addresses.


    3. Assign the static IP address
      To set a static IP address:
      1. Open Windows Start menu.
      2. Open Control Panel.
      3. Classic view: Open Network Connections
        Category view: Select Network and Internet Connections, and then Network Connections.
      4. Double-click on your active LAN or Internet connection.
      5. Click Properties.
        This opens the Local Area Connections Properties window.
      6. In the General tab, highlight the Internet Protocol (TCP/IP) item, and click Properties.
        LACproperties.gif
        LACproperties.gif (37.86 KiB) Viewed 14511 times


        This opens the Internet Protocol (TCP/IP) Properties window.
      7. In the General tab, click Use the following IP address, and enter:
        • IP address. The static IP address you want to assign to this computer.
        • Subnet mask. Subnet mask used by your router.
        • Default gateway. IP address of your router's default gateway.
      8. In Use the following DNS server addresses, enter all the IP addressses for the DNS servers your router uses.
      9. Click OK.
        tcp.gif
        tcp.gif (33.11 KiB) Viewed 14511 times


        Then:
      10. Click OK to close each window.
      11. Restart your computer.
      12. Then, check your IP address again, to make sure that the changes were applied.

    For example, let's say you picked the IP address 192.168.1.102. After the above step is completed, you should be able to get to the website on your local machine by going to both http://localhost and http://192.168.1.102, since your computer will now always have that IP address on your network.
  2. Configure Port Forwarding on your router
    We need to forward all packets that are coming to port 80 (web server) to your machine. This is done through port forwarding.
    This is done very easily by following steps.

    1. Login to you router
    2. Enable Port Forwarding (If there is a tick box)
    3. Go to Port Forwarding page and set Port 80 (Web Server) to be forwarded to your machine (Put your PC's IP there).

    There are differences in configuration on each brand/model. Here are some examples.
    DLinkPF.JPG
    DLinkPF.JPG (68.52 KiB) Viewed 14511 times


    LinkSysPF.gif
    LinkSysPF.gif (32.73 KiB) Viewed 14511 times


    NetGearPF.jpg
    NetGearPF.jpg (40.3 KiB) Viewed 14511 times

  3. Find your WAN IP
    If you look up your IP address (such as http://www.ip-adress.com/), the IP you see is actually the IP of your router (WAN IP). When your friend accesses your website, you'll give him this IP. Having done all that, your friend should now be able to access your web page by going to his web browser on his machine and entering http://IP.address.of.your.computer (the same one you see when you go here ).

  4. Assign a domain name to your IP
    Since DSL users usually get a dynamic IP, you have to always give your IP to your friend to access your web page. There is anice solution to come up with this. You can assign a domain name to your IP with a service called DynDns.

    DynDNS.JPG
    DynDNS.JPG (96.1 KiB) Viewed 14511 times


    After going through registration and email verification, finally you can see your domain is activated as below.
    DynDNSlist.JPG
    DynDNSlist.JPG (18.96 KiB) Viewed 14511 times


    Finally, download the DynDNS update client software and install it in your PC. Using an update client with your Dynamic DNS hostname allows you to make sure you can always reach your home network, because it makes sure that your hostname is always up-to-date with the latest IP address. The update client runs in the background, so once you have it properly configured you don't have to worry about it; you only need to remember your hostname to reach your files and services.
  5. Check access to localhost is allowed through internet
    In some cases we need to configure our web server to allow access to web server from internet.
    For example, on Apache server, you may have to do the following steps (If those are not already configured).

    1. Edit file C:\www\vhosts\localhost\.htaccess
      There will be these lines within:
      Code: Select all
      order deny,allow
      deny from all
      allow from 127.0.0.1

      Comment all of them out by placing a # sign at beginning of each line.

    2. Edit file C:\www\Apache22\conf\extra\httpd-vhosts.conf
      Find the first VirtualHost block... Which is the "localhost" block.

      You will see lines:
      Code: Select all
      <VirtualHost *:80>
      DocumentRoot "C:/www/vhosts/localhost/_"
      ServerName localhost
      ServerAlias 127.0.0.1


      Update line 'ServerAlias 127.0.0.1' to 'ServerAlias 127.0.0.1 my.domain.com'

      Note that you can add more domains and IP addresses [such as your LAN system IP] to this line.

      Save file. Restart Apache.

    The reason access is restricted (by default) under "localhost" to the local system is due to security issues. When the Suite is first installed some of the web apps are not fully finished with their installation process and it would be un-wise at that stage to open access to them on the internet.

    The reason you have to make the changes to httpd-vhosts.conf to bind "localhost" to additional IP addresses is a technical one. There is a conflict with a default Virtual Host and the dynamic domains feature of the Suite.

I wanted to provide a complete guide and hope this will help you!
User avatar
Neo
Site Admin
Site Admin
 
Posts: 2593
Joined: Tue Jul 14, 2009 8:37 pm
Cash on hand: 220,246.10
Bank: 15,536,454.00
Location: Colombo/London
Medals: 2
EC_Bronze_Star (1) EC_Achievment (1)

Invitations sent: 94
Registered friends: 12
Highscores: 13
Reputation point: 73
Lieutenant

Re: How to access website hosted in localhost from internet

Postby Neofriend » Tue Mar 23, 2010 10:19 am

the title sounds pretty interesting.... let me read in detail now :)
User avatar
Neofriend
 
Posts: 103
Joined: Wed Dec 23, 2009 10:07 am
Cash on hand: 3,771.80
Location: Pakistan
Medals: 1
EC_Achievment (1)

Invitations sent: 0
Registered friends: 0
Reputation point: 1
Lance Corporal

Re: How to access website hosted in localhost from internet

Postby thegtaguy » Fri Dec 17, 2010 3:25 pm

When Somebody Enters my WAN IP into their BROSWERS ADDRESS BAR they get an error saying :
Code: Select all
This Address may be temporarily down ...

When i enter MY WAN IP in my address bar i get redirected to my ROUTER Admin Panel !!

Please Help ME !!
User avatar
thegtaguy
 
Posts: 10
Joined: Fri Dec 17, 2010 3:18 pm
Cash on hand: 373.60
Bank: 0.00

Invitations sent: 0
Registered friends: 0
Reputation point: 0
Lance Corporal

Re: How to access website hosted in localhost from internet

Postby Neo » Fri Dec 17, 2010 4:21 pm

Foe me, it seems that you have not correctly setup port forwarding (Step 2). Can you check on that?
If you do not correctly forward port 80 (Web Server) to your machine, obviously you will expereince the issue you explained earlier.
User avatar
Neo
Site Admin
Site Admin
 
Posts: 2593
Joined: Tue Jul 14, 2009 8:37 pm
Cash on hand: 220,246.10
Bank: 15,536,454.00
Location: Colombo/London
Medals: 2
EC_Bronze_Star (1) EC_Achievment (1)

Invitations sent: 94
Registered friends: 12
Highscores: 13
Reputation point: 73
Lieutenant

Re: How to access website hosted in localhost from internet

Postby thegtaguy » Sun Dec 19, 2010 4:45 am

Neo wrote:Foe me, it seems that you have not correctly setup port forwarding (Step 2). Can you check on that?
If you do not correctly forward port 80 (Web Server) to your machine, obviously you will expereince the issue you explained earlier.

Actually , I had a Little Confusion ...
I wanted to Ask U ...
I have a DHCP connection , So my Default Gateway is 192.168.1.1 // This is Shown in MY CMD //
If i Go to IP-ADDRESS.com , I get a Different IP // You Know U Are the ADMIN // :D

If enter Both of them in my Address Bar Both Take me to the Router Authentication Page ...
Which one should i login to and edit ?

I'm Using Window 7 + XAMPP !!
Thanks ...
User avatar
thegtaguy
 
Posts: 10
Joined: Fri Dec 17, 2010 3:18 pm
Cash on hand: 373.60
Bank: 0.00

Invitations sent: 0
Registered friends: 0
Reputation point: 0
Lance Corporal

Re: How to access website hosted in localhost from internet

Postby Neo » Mon Dec 20, 2010 10:20 am

I have a DHCP connection , So my Default Gateway is 192.168.1.1 // This is Shown in MY CMD //
If i Go to IP-ADDRESS.com , I get a Different IP

If you want to forward port 80 to your web server, you will have to off the DHCP server on router and assign a static IP to your PC. Read the first post on that.

If enter Both of them in my Address Bar Both Take me to the Router Authentication Page ...
Which one should i login to and edit ?

Use the LAN IP to login to the admin page since all WAN IPs are then transfered to your PC.

I recommend WAMP since I'm working with that for years now without any issue.
User avatar
Neo
Site Admin
Site Admin
 
Posts: 2593
Joined: Tue Jul 14, 2009 8:37 pm
Cash on hand: 220,246.10
Bank: 15,536,454.00
Location: Colombo/London
Medals: 2
EC_Bronze_Star (1) EC_Achievment (1)

Invitations sent: 94
Registered friends: 12
Highscores: 13
Reputation point: 73
Lieutenant

Re: How to access website hosted in localhost from internet

Postby thegtaguy » Sat Dec 25, 2010 5:05 am

Thank You Very much my Website is up and Running on my IP ...
Can u tell me how can i configure my web mail , FTP .. etc.
Thank You !!
User avatar
thegtaguy
 
Posts: 10
Joined: Fri Dec 17, 2010 3:18 pm
Cash on hand: 373.60
Bank: 0.00

Invitations sent: 0
Registered friends: 0
Reputation point: 0
Lance Corporal

Re: How to access website hosted in localhost from internet

Postby Neo » Sat Dec 25, 2010 8:29 am

FTP

Download FileZilla Server and install.
Then forward Port 21 (FTP port) to your PC.

If you need to use FTPS, then you will also have to forward ports 989 and 990.
Code: Select all
989   TCP   UDP   FTPS Protocol (data): FTP over TLS/SSL
990   TCP   UDP   FTPS Protocol (control): FTP over TLS/SSL


web mail

Since webmail is operated through port 80 (Web Server), you don't need to do port forwarding for this.
However, you will have to find a mail server such as MDaemon. See http://www.altn.com/ for their products. They offer a free version for home users. See http://www.altn.com/Products/Free-Windows-Mail-Server/.

Hope that helps !
User avatar
Neo
Site Admin
Site Admin
 
Posts: 2593
Joined: Tue Jul 14, 2009 8:37 pm
Cash on hand: 220,246.10
Bank: 15,536,454.00
Location: Colombo/London
Medals: 2
EC_Bronze_Star (1) EC_Achievment (1)

Invitations sent: 94
Registered friends: 12
Highscores: 13
Reputation point: 73
Lieutenant

Re: How to access website hosted in localhost from internet

Postby Kevin » Sat Dec 25, 2010 8:39 am

Mdeamon Pro is at viewtopic.php?f=58&t=2171  ;)
User avatar
Kevin
 
Posts: 321
Joined: Sun Jul 19, 2009 2:19 pm
Cash on hand: 69,806.60
Location: Sydney

Invitations sent: 6
Registered friends: 0
Reputation point: 3
Lance Corporal

Re: How to access website hosted in localhost from internet

Postby thegtaguy » Sat Dec 25, 2010 4:37 pm

Neo wrote:
FTP

Download FileZilla Server and install.
Then forward Port 21 (FTP port) to your PC.

If you need to use FTPS, then you will also have to forward ports 989 and 990.
Code: Select all
989   TCP   UDP   FTPS Protocol (data): FTP over TLS/SSL
990   TCP   UDP   FTPS Protocol (control): FTP over TLS/SSL


web mail

Since webmail is operated through port 80 (Web Server), you don't need to do port forwarding for this.
However, you will have to find a mail server such as MDaemon. See http://www.altn.com/ for their products. They offer a free version for home users. See http://www.altn.com/Products/Free-Windows-Mail-Server/.

Hope that helps !

Okay ,
I have downloaded FileZilla Server.
I have to use NAT to port forward.
So i entered a new entry :
Code: Select all
Name "FileZilla"
IP "192.168.1.11"
Input Port "21"
Output "21"
Connection Type "TCP"

Are the Above Settings Correct or do i need to modify something ?
User avatar
thegtaguy
 
Posts: 10
Joined: Fri Dec 17, 2010 3:18 pm
Cash on hand: 373.60
Bank: 0.00

Invitations sent: 0
Registered friends: 0
Reputation point: 0
Lance Corporal

Next

Return to Web programming

Who is online

Users browsing this forum: No registered users and 2 guests