加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 运营中心 > Nginx > 正文

nginx不提供对外部IP地址的请求

发布时间:2020-12-13 21:40:27 所属栏目:Nginx 来源:网络整理
导读:我在端口81上运行nginx.我可以使用telnet 127.0.0.1进行telnet,一切都很好. 但是当我尝试从我的Mac(外部IP地址)telnet到我的机器时,我只是得到这个错误: telnet: connect to address 109.123.x.x: Connection refusedtelnet: Unable to connect to remote h

我在端口81上运行nginx.我可以使用telnet 127.0.0.1进行telnet,一切都很好.

但是当我尝试从我的Mac(外部IP地址)telnet到我的机器时,我只是得到这个错误:

telnet: connect to address 109.123.x.x: Connection refused
telnet: Unable to connect to remote host

这是我的/ etc / nginx / sites-available / default文件:

server {
        listen   81; ## listen for ipv4; this line is default and implied
        #listen   [::]:80 default ipv6only=on; ## listen for ipv6

        root /usr/share/nginx/www;
        index index.html index.htm;

        # Make site accessible from http://localhost/
        server_name 109.123.x.x;

        location / {
                # First attempt to serve request as file,then
                # as directory,then fall back to index.html
                try_files $uri $uri/ /index.html;
        }
        ...

我打开了Ubuntu防火墙(ufw)以允许端口81.

我现在完全被困住了.

有人有主意吗?

最佳答案
您有服务器名称

server_name 109.123.x.x;

这是错误的!!!!!

把任何名字都不是数字

server_name mywebsite.home;

并将mywebsite.home作为主机文件(/ etc / hosts)中的nginx服务器的IP,即在你的mac格式中

109.123.X.X mywebsite.home

其中X.X被数字替换

要么

如果您想提供所有请求,请简单地说

server_name _;

如果这不能解决问题,请查看下面的内容

它可能是你的防火墙,即阻止你的流量的iptables,或者你的nginx仅在本地主机上监听,即127.0.0.1

禁用防火墙

sudo ufw disable

检查端口81的侦听地址

sudo netstat -tulpn

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读