Nginx-Redis服务器设置502 Bad Gateway错误。

我在云 VM 上使用 redis 和 openresty 设置了这个 nginx.conf 文件。

my_nginx.conf -

worker_processes 1;
error_log logs/error.log;
events{
    worker_connections 1024;
}
http {
 server {
     listen 8080;
     location / {
       redis2_query set hello world;
       redis2_query get hello;
       redis2_pass 127.0.0.1:6379;
     }
  }
}

我以如下方式运行此配置

$nginx -p pwd/ -c my_nginx.conf

现在当我在本地浏览器中访问此 VM 的 IP 地址时,我会收到错误

502 bad gateway openresty/1.5.12.1

http://xxx.xxx.xxx.xxx:8080/

我犯了什么错误?

点赞
用户380774
用户380774
  1. 确保您的 nginx 配置正确:nginx -p pwd/ -c my_nginx.conf -t
  2. 确保您的 redis 服务器正在运行:redis-cli -p 6379
  3. 检查 error.log

我测试了您的配置,它能够工作。

2015-04-02 09:00:45