问题
I just want to make my IP public, so that it can be accessed from any where.I am using ubuntu 18.04
. Already installed apache2 and PHP. The index file located in /var/www/html/example.com/public_html/index.php
. In local host it is running and with in the same network i am able to access my website. Also made some changes in firewall.
here is my /etc/hosts
file configuration
127.0.0.1 localhost
127.0.1.1 amal
127.0.0.1 www.example.com
127.0.0.1 example.com
And etc/apache2/sites-avaliable/example.com.conf
file configuration
<VirtualHost *:80>
ServerName www.example.com
ServerAlias example.com
ServerAdmin admin@example.com
DocumentRoot /var/www/html/example.com/public_html
ErrorLog /var/www/html/example.com/log/error.log
CustomLog /var/www/html/example.com/log/access.log combined
</VirtualHost>
with this configuration i am able to access this webpages with my IP(192.168.255.24) any locally connected device. Now i want to public my IP and can access these webpages from anywhere, I don't know much about this. I followed some tutorials but failed. This is Firewall status
command
ufw status
outputStatus: active
To Action From
-- ------ ----
Apache Full ALLOW Anywhere
80 ALLOW Anywhere
443 ALLOW Anywhere
8080 ALLOW Anywhere
Apache Full (v6) ALLOW Anywhere (v6)
80 (v6) ALLOW Anywhere (v6)
443 (v6) ALLOW Anywhere (v6)
8080 (v6) ALLOW Anywhere (v6)
And in my jiofi router portforward included my 192.168.255.24
with port 80
but when ever i tried to access my website with the global IP, got from canyouseeme.org
it displays The connection has timed out
. How to solve this problem please help
回答1:
192.168.255.24 is a private ip, it cannot be accessed from the internet only from the intranet.
127.0.0.1: loopback address, only accessible from the same device (computer) it is like saying myself. If somene else says myself, it is not you any more.
To access you computer on an intranet from the internet, you will need to get your public address, you can do this by googling "which is my ip", just take note that most likely it is a dynamic address which may change every now and then.
This will be the address to use from outside of the intranet (from inside it most likely not work)
Second, you have to go into the configuration of the router connected to the internet and:
Reserv in the DHCP a specific address for the coputer hosting the webserver (I guess it would be 192.168.255.24 ). You need to do this for the computer to have always the same ip address in the intranet.
Configure port forwarding (also in the router) to redirect what is received on port 80 and if you will be using ssl port 443 for example to the reserved addresses (192.168.255.24 ) on port 80 and 443 respectively. In this way what comes in from the internet on ports 80 and 443 goes to the computer hosting the web server on the same port.
Third, you will need to check the computer's firewall rules to enable traffic on port 80.
Just a note of advice, when you enable the port forwarding in the router you are explicitly letting computers from the Internet access your intranet on the specific ports. I understand this is what you want, but I just wanted to make it clear.
来源:https://stackoverflow.com/questions/52137672/how-do-i-make-my-ip-public-externally-can-access-my-localhost