问题描述
我只想公开我的 IP,以便可以从任何地方访问它.我使用的是 ubuntu 18.04
.已经安装了apache2和PHP.位于 /var/www/html/example.com/public_html/index.php
中的索引文件.在本地主机中,它正在运行,并且在同一网络中我可以访问我的网站.还对防火墙进行了一些更改.
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.
这是我的/etc/hosts
文件配置
127.0.0.1 localhost
127.0.1.1 amal
127.0.0.1 www.example.com
127.0.0.1 example.com
和etc/apache2/sites-avaliable/example.com.conf
文件配置
<VirtualHost *:80>
ServerName www.example.com
ServerAlias example.com
ServerAdmin [email protected]
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>
使用此配置,我可以使用我的 IP(192.168.255.24)任何本地连接的设备访问此网页.现在我想公开我的 IP 并且可以从任何地方访问这些网页,我对此知之甚少.我遵循了一些教程但失败了.这是防火墙状态
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
命令
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)
在我的 jiofi 路由器中,portforward 包含了我的 192.168.255.24
和端口 80
但是当我尝试使用全局 IP 访问我的网站时,从 canyouseeme.org
获得它显示 连接超时
.请问如何解决这个问题
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
推荐答案
192.168.255.24 是私有 ip,不能从 Internet 访问,只能从 Intranet 访问.
192.168.255.24 is a private ip, it cannot be accessed from the internet only from the intranet.
127.0.0.1:环回地址,只能从同一设备(计算机)访问,就像我自己说的.如果别人说我自己,那已经不是你了.
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.
要从 Internet 访问 Intranet 上的计算机,您需要获取您的公共地址,您可以通过谷歌搜索这是我的 ip"来完成此操作,请注意它很可能是一个可能会更改的动态地址时不时.
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:
在 DHCP 中为托管网络服务器的计算机保留一个特定地址(我猜应该是 192.168.255.24 ).您需要执行此操作以使计算机在 Intranet 中始终具有相同的 IP 地址.
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.
配置端口转发(也在路由器中)以重定向在端口 80 上接收到的内容,如果您将使用 ssl 端口 443,例如分别到端口 80 和 443 上的保留地址(192.168.255.24).通过这种方式,来自 Internet 端口 80 和 443 的内容将传送到在同一端口上托管 Web 服务器的计算机.
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.
第三,您需要检查计算机的防火墙规则以启用端口 80 上的流量.
Third, you will need to check the computer's firewall rules to enable traffic on port 80.
请注意,当您在路由器中启用端口转发时,您明确允许来自 Internet 的计算机通过特定端口访问您的内联网.我明白这就是你想要的,但我只是想说清楚.
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.
这篇关于我如何公开我的 IP,外部可以访问我的本地主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!