Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using a variable in the resolver directive #1506

Open
RoeiRom opened this issue Oct 5, 2020 · 2 comments
Open

Using a variable in the resolver directive #1506

RoeiRom opened this issue Oct 5, 2020 · 2 comments

Comments

@RoeiRom
Copy link

RoeiRom commented Oct 5, 2020

Hi,
I'm trying to use the resolver directive with an environment variable because DNS resolver 127.0.0.11 didn't work. However when I am running my docker container I get the folloeing error nginx: [emerg] host not found in resolver "$resolver_ip" in /usr/src/app/nginx.conf:25. I'm adding the Docker file and the nginx.conf
Dockerfile

FROM nginx:1.14.2-alpine

RUN  mkdir -p /run/nginx && \
     apk add nginx-mod-http-lua
     
WORKDIR /usr/src/app

COPY build /usr/src/app/build
COPY mime.types /usr/src/app

COPY nginx.conf /usr/src/app

EXPOSE 8080

CMD [ "nginx", "-c", "/usr/src/app/nginx.conf", "-g", "daemon off;" ]

nginx.conf

load_module /usr/lib/nginx/modules/ndk_http_module.so;
load_module /usr/lib/nginx/modules/ngx_http_lua_module.so;

env SERVER_URL;
env RESOLVER_IP;

pcre_jit on;

events {

}

http {

    lua_load_resty_core off;

    include /usr/src/app/mime.types;
    default_type  application/octet-stream;

    sendfile on;


    server {
        set_by_lua $resolver_ip 'return os.getenv("RESOLVER_IP")';

        resolver $resolver_ip;
        
        set_by_lua $server_url 'return os.getenv("SERVER_URL")';

        listen 8080;

        location /db/ {
            rewrite ^/db(.*)$ $1 break;
            proxy_pass $server_url/clientToDBApi$uri$is_args$args;
        }

        location / {
            root /usr/src/app/build;
            index index.html;
            try_files $uri $uri/ /index.html;
        }
    }
}

please help, couldn't get into the google group

@tkw1536
Copy link
Collaborator

tkw1536 commented Nov 2, 2020

This looks like a general nginx issue, not one related to the nginx-proxy docker image.

@avsdev-cw
Copy link

I agree, however the only real use case for "resolver" is when using nginx as a proxy and this repo hits high on google.

I've opened an official ticket for this:
https://trac.nginx.org/nginx/ticket/2128#ticket

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants