我在 Ubuntu 服务器 (digital ocean) 上运行 Nginx,我已设置 LEMP 堆栈来托管 Wordpress 网站。我得到了501 网关错误当我尝试使用 IP 地址访问网站时。
我在日志中看到以下错误:
2022/05/24 14:43:52 [error] 199802#199802: *3 connect() failed (111: Connection refused) while connecting to upstream, client: 212.58.120.29, server: localhost, request: "GET /ttemp.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "46.101.238.240"
2022/05/24 14:43:52 [error] 199802#199802: *3 connect() failed (111: Connection refused) while connecting to upstream, client: 212.58.120.29, server: localhost, request: "GET /favicon.ico HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "46.101.238.240", referrer: "https://46.101.238.240/ttemp.php"
这是我的 Nginx 配置:
server {
listen 80;
listen 443 ssl;
ssl_certificate /var/www/ssl/default.crt;
ssl_certificate_key /var/www/ssl/default.key;
server_name localhost mydomain.com www.mydomain.com;
root /var/www/mydomain.com;
error_log /var/log/nginx/error.log info;
location / {
try_files $uri $uri/ /index.php?$args;
index index.html index.htm index.php;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
我的 UFW 状态:
To Action From
-- ------ ----
Nginx HTTP ALLOW Anywhere
Nginx HTTPS ALLOW Anywhere
22/tcp ALLOW Anywhere
22 ALLOW Anywhere
2222 ALLOW Anywhere
3306 ALLOW Anywhere
80 ALLOW Anywhere
443 ALLOW Anywhere
9000 ALLOW Anywhere
Nginx HTTP (v6) ALLOW Anywhere (v6)
Nginx HTTPS (v6) ALLOW Anywhere (v6)
22/tcp (v6) ALLOW Anywhere (v6)
22 (v6) ALLOW Anywhere (v6)
2222 (v6) ALLOW Anywhere (v6)
3306 (v6) ALLOW Anywhere (v6)
80 (v6) ALLOW Anywhere (v6)
443 (v6) ALLOW Anywhere (v6)
9000 (v6) ALLOW Anywhere (v6)
有任何想法吗?