我有端口81上运行的nginx。我可以使用telnet 127.0.0.1 81 ,一切都很好。
但是,当我尝试从我的Mac远程login到我的机器(外部IP地址),我只是得到这个错误:
telnet: connect to address 109.123.xx: 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.xx; location / { # First attempt to serve request as file, then # as directory, then fall back to index.html try_files $uri $uri/ /index.html; } ...
我打开了Ubuntu Firewall(ufw)来允许端口81。
我现在完全卡住了。
有人有主意吗?
你有服务器名称
server_name 109.123.xx;
这是错误的!
把任何名字不像数字
server_name mywebsite.home;
并将mywebsite.home作为您的主机文件(/ etc / hosts)中的nginx服务器的IP,即在您的mac中,如格式
109.123.XX mywebsite.home
XX被replace为数字
要么
如果你想服务于所有的要求,简单地说
server_name _;
如果这样不能解决问题,请查看下面的内容
这是要么你的防火墙,即iptables阻止你的stream量,或者你有你的nginx只听本地,即127.0.0.1
禁用防火墙
sudo ufw disable
检查端口81的监听地址
sudo netstat -tulpn
帮助我的提示:A.)端口转发B.)将公共IP设置为server_name这些步骤对我来说尤其适用A.)