Skip to content
This repository has been archived by the owner on Dec 1, 2023. It is now read-only.

Ignore "Host not found" in nginx location #44

Closed
veerendra2 opened this issue Dec 27, 2022 · 4 comments
Closed

Ignore "Host not found" in nginx location #44

veerendra2 opened this issue Dec 27, 2022 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@veerendra2
Copy link
Owner

veerendra2 commented Dec 27, 2022

Ngnix is failing to start if any of specified location is down

/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: info: can not modify /etc/nginx/conf.d/default.conf (read-only file system?)
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
/docker-entrypoint.sh: Configuration complete; ready for start up
2022/12/27 20:36:03 [emerg] 1#1: host not found in upstream "pihole" in /etc/nginx/conf.d/locations/pihole.conf:2
nginx: [emerg] host not found in upstream "pihole" in /etc/nginx/conf.d/locations/pihole.conf:2
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh

Solutions

@veerendra2 veerendra2 added the bug Something isn't working label Dec 27, 2022
@veerendra2 veerendra2 self-assigned this Dec 27, 2022
@veerendra2
Copy link
Owner Author

veerendra2 commented Dec 27, 2022

UPDATE; It worked due to browser cache

@veerendra2
Copy link
Owner Author

Tried below config

location /admin/ {
  resolver 127.0.0.11 valid=30s;
  set $upstream pihole;

  proxy_pass http://$upstream/admin/;  #http://pihole:80/admin/; #$upstream;
  proxy_set_header Host $http_host;
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_hide_header X-Frame-Options;
  proxy_set_header X-Frame-Options "SAMEORIGIN";
  proxy_read_timeout 90;
}
  • Above config is not working in browser with This problem can sometimes be caused by disabling or refusing to accept cookies. and HTTP 302 error, but the endpoint seems up when try with httpie
$  http --verify=no  --check-status https://192.168.0.120/admin/login.php
HTTP/1.1 302 Found
Cache-Control: no-store, no-cache, must-revalidate
Connection: keep-alive
Content-Length: 0
Content-Security-Policy: default-src 'self' 'unsafe-inline';
Content-Type: text/html; charset=UTF-8
Date: Thu, 29 Dec 2022 22:30:27 GMT
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Location: login.php
Pragma: no-cache
Referrer-Policy: same-origin
Server: nginx/1.23.2
Set-Cookie: PHPSESSID=33cobiugh16cqg4i89aus42l8i; path=/; HttpOnly; SameSite=Strict
X-Content-Type-Options: nosniff
X-Permitted-Cross-Domain-Policies: none
X-Pi-hole: The Pi-hole Web interface is working!
X-XSS-Protection: 1; mode=block
  • Even the browser gets redirect to https://192.168.0.120/admin/login.php when homer has https://192.168.0.120/admin/
  • Tried with upstream with max_fails=3 fail_timeout=30s; and resolver, but no luck!
  • DNS resolving is work
veerendra@atom:/opt/apps/nginx$ docker exec -it nginx nslookup pihole 127.0.0.11
Server:         127.0.0.11
Address:        127.0.0.11:53

Non-authoritative answer:
Name:   pihole
Address: 172.18.0.5

Non-authoritative answer:

@veerendra2
Copy link
Owner Author

  • Working when I remove varaible in proxy_pass
  • The nginx is failing to start if it cant resolve the host. Can't found a why how to prevent stopping the host is down. Tried with set too

@veerendra2
Copy link
Owner Author

Closing the issue, cant find fix. Maybe switch to caddy in future

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
No open projects
Status: Done
Development

When branches are created from issues, their pull requests are automatically linked.

1 participant