Nginx SSL配置正常但访问提示Server Not Found且日志为空
Let's break down why you're seeing "Server Not Found" and why your logs are empty—this usually means your request isn't even reaching Nginx in the first place. Here's what to check step by step:
1. First: Verify DNS Resolution
The "Server Not Found" error is a browser-level issue indicating it can't resolve myapp.xyz to an IP address.
- On your local machine, run:
ping myapp.xyz # Or for more detailed DNS info: nslookup myapp.xyz - Make sure the returned IP matches your server's public IP. If not, you need to fix your domain's DNS records (update the A/AAAA record to point to your server's correct public IP).
2. Check if Nginx is Actually Listening on Port 443
Your netstat output only shows ports 80 and 8069 being listened on, but your config includes a server block for 443. Let's confirm Nginx is monitoring that port:
netstat -tulpn | grep :443
If you don't see nginx in the results, your SSL server block isn't being loaded. Common fixes:
- Check your main
nginx.confforincludedirectives (likeinclude /etc/nginx/conf.d/*.conf;orinclude /etc/nginx/sites-enabled/*;) and ensure your site config is in the correct directory to be picked up. - Reload Nginx to apply any unloaded config changes:
nginx -s reload
3. Validate Firewall/Security Group Rules
Even if Nginx is listening, incoming traffic on 80/443 might be blocked by a server firewall or cloud security group:
For Linux firewalld:
# Check current allowed services firewall-cmd --list-all # Add HTTP/HTTPS if missing firewall-cmd --add-service=http --permanent firewall-cmd --add-service=https --permanent # Reload to apply changes firewall-cmd --reload
For iptables:
# View existing rules iptables -L -n # Allow inbound HTTP/HTTPS traffic iptables -A INPUT -p tcp --dport 80 -j ACCEPT iptables -A INPUT -p tcp --dport 443 -j ACCEPT # Save rules (distro-specific, e.g., Debian/Ubuntu: `iptables-save > /etc/iptables/rules.v4`)
Cloud Platforms (AWS/Azure/GCP):
Don't forget to check your cloud security group settings—ensure inbound traffic on 80 (HTTP) and 443 (HTTPS) is allowed from your IP (or 0.0.0.0/0 if the app is public-facing).
4. Confirm Nginx Configuration is Fully Loaded
Even though nginx -t passed, double-check your site config is being included:
- Open
/etc/nginx/nginx.confand verify there's anincludeline pointing to your config's directory. For example, if your config is in/etc/nginx/sites-available/myapp.conf, make sure you've created a symlink to thesites-enableddirectory (common on Debian/Ubuntu):ln -s /etc/nginx/sites-available/myapp.conf /etc/nginx/sites-enabled/
Then reload Nginx again to ensure changes take effect.
5. Quick Test: Bypass DNS
To rule out DNS issues entirely, edit your local hosts file:
- On Windows:
C:\Windows\System32\drivers\etc\hosts - On Linux/macOS:
/etc/hosts
Add a line like:
<your-server-public-IP> myapp.xyz
Then try accessing myapp.xyz again. If it works, you know the problem is definitely with DNS resolution.
内容的提问来源于stack exchange,提问作者ShivaGuntuku

