nginx-proxy / nginx-proxy/nginx-proxy

Using a variable in the resolver directive

Open
#1,506 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
19.9k
Forks
3k
Avg merge
2d 11h
Merged PRs (30d)
1

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the resolver and set_by_lua directives in nginx.conf, then inspect the Dockerfile and the container startup environment for how RESOLVER_IP is supplied. Reproduce the nginx startup error and determine what configuration is needed for the resolver value to be accepted; done means the container starts without the reported host-not-found error.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, lua, nginx
Domain
infrastructure, networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.