【问题标题】:Open resty lua script in localhost:8082 not resolving http://localhost/foo/hostname在 localhost:8082 中打开 resty lua 脚本不解析 http://localhost/foo/hostname
【发布时间】:2023-01-27 12:46:29
【问题描述】:

我正在尝试使用在 Windows 10 机器上运行的 wsl-Ubuntu 中使用 proxy_pass 的开放式 resty lua 脚本来访问本地主机服务(http://localhost/foo/hostname)。

这是内容nginx 配置文件

worker_processes 2;

events {
        worker_connections 1024;
}

http {
        server {
                listen 8082;

                location /{
                        resolver 8.8.4.4;

                        set $target 'localhost/foo/hostname';

                        proxy_pass http://$target;
                }
        }
}

我有一个 '502错误的网关' 对 localhost:8082 进行卷曲时的响应 这是在中发现的错误错误日志文件

2023/01/27 09:31:17 [error] 331#331: *1 localhost could not be resolved (110: Operation timed out), client: 127.0.0.1, server: , request: "GET / HTTP/1.1", host: "localhost:8082"

我尝试了各种解决方案,包括修改解析器选项。

【问题讨论】:

    标签: nginx lua wsl-2 proxypass openresty


    【解决方案1】:

    这是通过指定本地主机 IP 地址 (127.0.0.1)代替本地主机在具体的网址中。

    worker_processes 2;
    
    events {
            worker_connections 1024;
    }
    
    http {
            server {
                    listen 8082;
    
                    location /{
                            resolver 8.8.4.4;
    
                            set $target '127.0.0.1/foo/hostname';
    
                            proxy_pass http://$target;
                    }
            }
    }
    

    如果有人知道无法解决的实际情况或原因是什么 '本地主机' 但可能与 '127.0.0.1',请分享您的知识。

    【讨论】:

      猜你喜欢
      • 2015-01-30
      • 1970-01-01
      • 1970-01-01
      • 2021-08-21
      • 1970-01-01
      • 1970-01-01
      • 2015-12-07
      • 2013-08-19
      • 2021-05-15
      相关资源
      最近更新 更多