运行 Ubuntu Server v23,使用 NGINX 和“静态”IP 地址(通过 noip)。从我的服务器 ping 公共 IP 并看到以下内容:
通过 Web 服务器:IP192.168.1.43
root@websrv:/etc/nginx/conf.d# ping TheSite.com
PING TheSite.com (50.47.211.xxx) 56(84) bytes of data.
64 bytes from 50-47-211-xxx.evrt.wa.ptr.ziplyfiber.com (50.47.211.xxx): icmp_seq=1 ttl=64 time=0.077 ms
我从 LAN Windows 机器 ping 同一个 IP:
Pinging 50.47.211.xxx with 32 bytes of data:
Reply from 50.47.211.xxx: bytes=32 time<1ms TTL=63
然后我尝试解析 DNS:
C:\Users\shawn>curl TheSite.com --verbose
* Trying 50.47.211.xxx:80...
* connect to 50.47.211.xxx port 80 failed: Timed out
* Failed to connect to TheSite.com port 80 after 21052 ms: Couldn't connect to server
尝试 curl IP 会产生相同的结果。但是,如果我 curl 服务器的 LAN IP,它就会起作用:
root@websrv:/home/shawn# curl 192.168.1.43 --verbose
* Trying 192.168.1.43:80...
* Connected to 192.168.1.43 (192.168.1.43) port 80 (#0)
> GET / HTTP/1.1
> Host: 192.168.1.43
> User-Agent: curl/7.88.1
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: nginx
< Date: Mon, 09 Oct 2023 07:09:01 GMT
< Content-Type: text/html; charset=utf-8
< Content-Length: 615
< Last-Modified: Mon, 23 May 2022 23:59:19 GMT
< Connection: keep-alive
< ETag: "628c1fd7-267"
< Accept-Ranges: bytes
<
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
* Connection #0 to host 192.168.1.43 left intact
root@websrv:/home/shawn#
局域网上的 Windows 机器也出现了同样的情况:
C:\Users\shawn>curl 192.168.1.43 --verbose
* Trying 192.168.1.43:80...
* Connected to 192.168.1.43 (192.168.1.43) port 80 (#0)
> GET / HTTP/1.1
> Host: 192.168.1.43
> User-Agent: curl/8.0.1
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: nginx
这是我的 NGINX 配置:
worker_processes 2;
user www-data;
events {
use epoll;
worker_connections 128;
}
error_log /var/log/error.log; #info;
http {
server_tokens off;
include mime.types;
default_type application/octet-stream;
charset utf-8;
index index.html
access_log /var/log/access.log combined;
sendfile on;
server {
server_name TheSite.com;
listen 80;
# server_name TheSite.com;
location /{
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_pass http://localhost:80/;
# auth_basic "closed site";
# auth_basic_user_file htpasswd;
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
我已禁用所有防火墙(uwf disable
),并在我的路由器(orbi pro)中将 DMZ 设置为服务器 LAN IP、端口转发 80,并禁用端口扫描和 DoS 保护:
我已经为此绞尽脑汁好几天了,这是我第一次设置 ubuntu 网络服务器。我现在正式陷入困境了……我完全不知所措,我向你们求助,并谦卑地请求你们的帮助,超级用户社区。