Eam*_*orr 12 nginx ip ip-address
我的 nginx 在端口 81 上运行。我可以使用 telnet telnet 127.0.0.1 81,一切都很好。
但是当我尝试从我的 Mac(一个外部 IP 地址)telnet 到我的机器时,我只是收到这个错误:
telnet: connect to address 109.123.x.x: Connection refused
telnet: Unable to connect to remote host
Run Code Online (Sandbox Code Playgroud)
这是我的 /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;
}
...
Run Code Online (Sandbox Code Playgroud)
我已打开 Ubuntu 防火墙 (ufw) 以允许端口 81。
我现在完全被困住了。
谁有想法?
kaj*_*aji 18
您的服务器名称为
server_name 109.123.x.x;
Run Code Online (Sandbox Code Playgroud)
这是错误的!!!!!
输入任何名称而不是数字
server_name mywebsite.home;
Run Code Online (Sandbox Code Playgroud)
并将 mywebsite.home 作为 nginx 服务器的 IP 放在您的主机文件(/etc/hosts)中,即在您的 mac 中,就像格式一样
109.123.X.X mywebsite.home
Run Code Online (Sandbox Code Playgroud)
其中 XX 被数字替换
或者
如果您想为所有请求提供服务,只需输入
server_name _;
Run Code Online (Sandbox Code Playgroud)
如果这不能解决问题,请检查以下内容
要么是您的防火墙,即 iptables 阻止了您的流量,要么是您的 nginx 仅在 localhost 上侦听,即 127.0.0.1
禁用防火墙
sudo ufw disable
Run Code Online (Sandbox Code Playgroud)
检查81端口的监听地址
sudo netstat -tulpn
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
68867 次 |
| 最近记录: |