Contents To fold

I. Principle

II. notations

III. Preparation

III-A. Does your PC have a fixed IP address or not?

III-B. Does your ADSL connection have a fixed IP address or not?

III-C. What name do you want to use to access your site?

III-D. Port selection

IV. Web server installation

V. Configure the web server for access from the outside

VI. Configure the ADSL router

VII. Test

VIII. Troubleshooting

VIII-A. It works from the outside but not internally

You have a high-speed Internet connection at home and you want to install a web server on your PC and make sure that your friends and family can access it. This article is here to help you: it will guide you in the realization of this project.

Article read 153187 times.

I. Principle ▲

The operation you want to do is really difficult only compared to your ADSL router and your Internet connection: indeed, your ADSL router protects external access machines in your home. One of the important steps will therefore be to open a door to your PC in your router.

Then, your friends and families need to know how to connect to your site: which URL to use? This question is one of the important issues of preparation. Overall, the configuration to put in place must answer this:

Principle of the configuration

Principle of the configuration

The operation therefore takes place in several stages:

Preparation

Install the web server

Configure the server for access from the outside

Configure the ADSL router (or other)

Test

II. Notations ▲

To simplify the following, we will use the following notations:

notation   Description

<PC IP>   IP address of your PC

<Www.monsite.com> name (or IP address) that you will use in the URLs to access your site. See below the implications of using the IP address in the case of a dynamic address.

<website port> it is a number between 1 and 65535. This is the port through which your website is accessible. The most common case is to use 80. In this case, the URLs of your site will be of the style http://www.mysite.com/path. If this port is not 80 (764 for example), the URLs will look like http://www.mysite.com:764/path.

III. Preparation ▲

Before embarking on the required installations and configurations, it is necessary to answer a certain number of preliminary questions that determine the conditions of access to your site.

III-A. Does your PC have a fixed IP address or not? ▲

The door we are going to open in your router will actually be sending back all your incoming connections to your PC. For this, your router must know the IP address of your PC. If this address is dynamic, it may be that in some cases (for example depending on the start order of your different machines) your PC does not always get the same address.

If you have multiple machines in your home, it is strongly recommended that you set up a fixed IP address on your PC.

On Windows, To know if your PC has a dynamic IP address, proceed as follows:

Click on the Start menu and click on Run …

In the window that opens, type “cmd” (without the quotation marks) and press Enter

Type the command “ipconfig / all” (without the quotation marks) and press Enter

If you see something like “Lease got it”, it means that your PC has a dynamic IP address

To configure a static IP address, you must change the connection properties of your PC. If you want to use the same IP address dynamically, remember to configure your router to not distribute this address.

III-B. Does your ADSL connection have a fixed IP address or not? ▲

This question is different from the previous one: as much in the first question, you have possibilities of parameterization, so much here, it is about knowing how your Internet access is identified from the outside. To find out whether your connection has a fixed IP address or not, you must inquire with your service provider. This information is certainly available in the administration interface of your ADSL connection or router.

This question determines the possibilities you have to choose a name for your site (see next question).

III-C. What name do you want to use to access your site? ▲

The question is here: what URL to type in a browser to access my site? This can be http: // <IP address of my ADSL connection> /, http://www.monsiteamoi.com/, etc.

You can only use URLs in http: // <IP address of my ADSL connection> / if your ADSL IP address is fixed. If this is your case and such addresses are right for you, do not ask yourself more questions and proceed to the next step. On the other hand, if your ADSL address is dynamic, you have no choice but to go through a name. Indeed, if the IP address changes, it means that the URLs of your site change. People who know your site by your old address will no longer be able to access it. Only a name allows to maintain an independence vis-à-vis the IP address.

Otherwise, if you want a name, you have two possibilities depending on the answer to question III-B:

If your connection has a fixed IP address, you can potentially use any name. So you can buy an Internet domain and then configure it to point to the IP address of your ADSL connection. However, you must purchase your domain from a registrar that allows you to do advanced DNS setup. You can also apply the possibilities offered for the case of dynamic IP addresses (next point).

If your connection has a dynamic IP address, you have two options:

Simple solution: you go through a DynDNS or No-IP style utility. You must then install a program on your PC that will automatically update the DynDNS or No-IP servers with the IP address of your Internet connection. The services of these sites are free if you choose to use one of their subdomains as the address of your site (for example, toto.dyndns.org, titi.dyndns.org, tata.no-ip.com). Note that Free offers an equivalent service in .free.fr for unbundled access. With the free version of these services, you will not be able to use your own domain name (www.monsiteamoi.com), what you can however do while going through paid services (what No-IP offers for example). If this solution does not satisfy you, contact your service provider to find out how to obtain a fixed IP address.

More complicated solution: you have already bought a domain and you do not want to go through the paid services of DynDNS or No-IP. In this case, you must try to set up an advanced DNS configuration with the registrar, possibly using a free service of the DynDNS or No-IP type. This solution requires advanced knowledge in DNS configuration and has no guarantee of success.

When your choice is stopped, create your account at DynDNS, No-IP or equivalent, buy your domain or buy the services that go well and that will meet your needs. Then proceed to the installation and configuration of these services. Before proceeding with the operations, you must be sure that this name configuration works well and points to the IP address of your connection. To check it, open a command interpreter (for Windows, it’s Start menu, then Run … then cmd) and type the following command:

Select

ping <le nom que vous avez choisi pour votre site>

This command should display the IP address of your Internet connection. If this is not the case, there is a problem that you must solve before moving on. Test this order with different people to make sure they can access your site.

III-D. Port selection

Choose a port for access to your site. If you have no idea what it is or do not want this port listed in your site’s URLs, choose 80.

IV. Installing the Web server ▲

For this part, you are free to choose the web server that suits you best. On Windows, if you do not have IIS, the easiest thing is to install a ready-made AMP solution (Apache + MySQL + PHP) such as EasyPHP or Wamp , for example.

V. Configure the web server for access from the outside ▲

Once installed, you must configure the web server.

First step: make sure you can access the web server from another machine. Generally, when installing an Easy PHP solution, the Apache server (the Web server) is accessible only from the machine on which it is installed. This is not enough: you have to make the server accessible from another machine. For that :

If you use IIS:

Open the IIS Admin Console

Go to the properties of the site (most certainly “default site”)

In the Website tab, choose “All Available” in the IP Address list

Specify <Web Site Port> in the TCP Port field

OK

Restart IIS and test that it works well

If you have installed a solution based on the Apache server:

Edit the Apache configuration file (usually called httpd.conf)

In this file, locate the line that starts with “Listen …”

Modify this line to remove any IP address there and specify your <web site port>. Example:

Select

Listen 127.0.0.1:80 => Listen <port site Web>

For Linux users, if <web site port> is less than 1024, it is advisable to specify another port number greater than 1024 and enter this number when configuring the router. This avoids having to start Apache with the root user.

Locate the line that starts with “Port …”

Then enter <website port>:

Select

Port <port site Web>

Look for lines that start with “Allow from …”. If you find one and the line contains 127.0.0.1 or <IP PC>, add a # to the beginning of the line:

Select

# Allow from 127.0.0.1

Look at the few lines immediately above and below: If you find a line “Order …” and / or “Deny from all”, also put a # in front. Full example:

Select

# Order Deny,Allow

# Deny from all

# Allow from 127.0.0.1

Save the file

Restart Apache and check that it works well

Then we configure the server name:

If you use IIS:

Open the IIS Admin Console

Go to the properties of the default site

On the Web Site tab, click the Advanced … button next to the IP Address field

Select the first line “Default” and click on theA Edit … button

In the Value field of the Host header, enter the name (or IP address) that will be used to access your site and that will appear in the URLs

Click OK to validate your change

Restart IIS and test

If you have installed a solution based on the Apache server:

Edit the Apache configuration file again (usually called httpd.conf)

In this file, locate the line that starts with “ServerName …”

Edit this line to indicate the name (or IP address) that will be used to access your site and that will appear in the URLs. For example :

Select

ServerName www.monsite.com

Save the file

Restart Apache and check that it works well

VI. Configure the ADSL router ▲

To access your website, visitors will go through your ADSL router. You must configure the latter to return HTTP requests to your website. To do this, open the administration console of your ADSL router and go to the advanced configuration / port forwarding section. Then configure the router to return all TCP traffic (UDP is useless) arriving on the port <Web site port> on <IP PC> (= the PC on which you installed your Web server) and on the port that you specified the Apache Listen directive or the IIS console port field. Validate the configuration and reboot your router.

VII. Test ▲

Critical moment: test access from the outside !! First test access from home: open a web browser and type the URL http://www.mysite.com:<port website> / (if <port website> = 80, do not bother to indicate it: http://www.mysite.com/). If everything is working properly, go to an acquaintance who has access to the Web (or ask for it) and test with the same URL. If you have a problem, consult.

VIII. Troubleshooting ▲

If there is a problem with this procedure, you can post a message on the Servers forum detailing as much as possible the problem encountered and the step you have taken.

VIII-A. It works from outside but not internally ▲

Access to your site may be working properly from outside, but not from your internal network (for example, you come across your router’s administration page or nothing happens). Technically, there is a good chance that there is a routing problem. It’s pretty tricky to adjust. The simplest workaround is to modify the etc / hosts file of each machine on the local network (on Linux, this is the file / etc / hosts, on Windows, it is the file C: \ WINDOWS \ system32 \ drivers \ etc \ hosts) to directly match the name of your site with the server’s local IP address: