502错误的网关-NGINX未定义要解析的解析器 [英] 502 Bad Gateway - NGINX no resolver defined to resolve

查看:90
本文介绍了502错误的网关-NGINX未定义要解析的解析器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为多个URL创建了一个代理通行证.

I have created a proxy pass for multi URLs.

    listen 80;
    listen [::]:80;

    server_name ~^(.*)redzilla\.11\.75\.65\.21\.xip\.io$;

            location / {
                    set $instname $1;
                    proxy_pass http://${instname}redzilla.localhost:3000;
            }

当我使用Chrome调用此服务时,触发了502错误.

When I call to this service using chrome, It was triggered 502 error.

http://test.redzilla.11.75.65.21.xip.io/

http://test.redzilla.11.75.65.21.xip.io/

我通过对网址进行硬编码将其放置在位置标记下方.

I put below location tag by hard coding the URL.

            location /redzilla {
                    proxy_pass http://test.redzilla.localhost:3000;
            }

然后它仅适用于以上URL.我想知道如何在单个位置标记内为多个URL创建代理传递.(请注意:URL模式为* .redzilla.localhost:3000,*(星号)代表任何单词)

Then It is working for only above URL. I want to know how to create proxy pass for multiple URL within single location tag. ( please note : URL pattern is *.redzilla.localhost:3000 , * ( star ) represent any word)

推荐答案

如果在docker内部使用nginx,请使用docker network create ...定义一个网络.标记为docker run),将向其中添加dns解析器,可通过127.0.0.11进行访问.

If you are using nginx inside docker, define a network, using docker network create .... Containers that are part of that network (through the --network flag on docker run), will have a dns resolver added to them, available via 127.0.0.11.

然后在您的服务器{}指令中添加"resolver 127.0.0.11;"

Then in your server {} directive add "resolver 127.0.0.11;"

这篇关于502错误的网关-NGINX未定义要解析的解析器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆