Open cmthomps opened 3 years ago
I'm also facing a similar issue trying this approach, it looks like the host name can't be resolved with this setup anymore.
...myapp could not be resolved (3: Host not found)...
In my case, the hostname lookup failed because the ECS task is not up yet. Maybe you could try adding this to your nginx section:
depends_on:
- app
Btw from the official docker compose documentation, service.links
is not (no longer?) implemented.
try adding this :
web:
image: nginx:alpine
working_dir: /app
restart: unless-stopped
volumes:
- .:/app
- ./.docker/nginx/nginx.conf:/etc/nginx/conf.d/default.conf
port:
- ...
depends_on:
- php-fpm
networks:
- nginx_net
app:
image: php:7-fpm
working_dir: /app
restart: unless-stopped
volumes:
- .:/app
- ...
environment:
....
networks:
- nginx_net
Had the same error in a different project. Once I switched from nginx:1.23.3-alpine
to nginx:1.23.3
it worked without any further adjustments. Not sure why the alpine image wasn't able to find the host, though.
After I changed from "alpine" to "1.22.0-alpine" (didn't check on newer versions), it's working.
Using nginx:1.25.2 but still facing with this issue.
2023/08/23 12:01:33 [emerg] 1#1: host not found in upstream "$server_two" in /etc/nginx/conf.d/alb.conf:32 nginx: [emerg] host not found in upstream "$server_two" in /etc/nginx/conf.d/alb.conf:32
my environment is: Win 10 WSL2 Docker
docker-compose.yml
` version: "3" services: app: image: nginx:1.25.2 container_name: "load_balancer_nginx" ports:
` nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful
events {}
http { include /etc/nginx/conf.d/*.conf; }
server {
listen 8000;
server_name server.one;
root /var/www/html/server.one/;
charset utf-8;
index index.html;
location / {
try_files $uri $uri/ =404;
}
}
server {
listen 8088;
server_name server.two;
root /var/www/html/server.two/;
charset utf-8;
index index.html;
location / {
try_files $uri $uri/ =404;
}
}
map $scheme $server_two {
default server.two:8088;
}
upstream all {
keepalive 20;
server server.one:8000 fail_timeout=999s max_fails=999999;
#server $server_two;
}
server {
listen 80;
server_name magento_alb.loc;
absolute_redirect off;
location / {
set $backend_servers all;
proxy_pass http://$backend_servers;
#proxy_pass http://$backend_servers:8080;
#proxy_pass http://all/;
proxy_pass_request_headers on;
proxy_set_header Host $host;
#proxy_set_header Host magento_alb.loc;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_redirect off;
proxy_intercept_errors on;
proxy_cache off;
}
}
`
Could someone help me to figure this out ?
I'm getting the same error on docker hub, can you help me with this? nginx: [emerg] host not found in upstream "openems-ui" in /etc/nginx/nginx.conf:31
These are my nginx.conf configration file
worker_processes 1;
events { worker_connections 1024; }
http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 5;
server {
#listen 80;
#server_name localhost 127.0.0.1;
listen 80;
root /usr/share/nginx/html/;
rewrite_log on;
location / {
rewrite ^ /m/$args last;
}
location /m/ {
index index.html;
try_files $uri$args $uri$args/ /index.html;
}
location / {
proxy_pass http://openems-ui:80;
proxy_set_header X-Forwarded-For $remote_addr;
}
location /backend {
proxy_pass http://openems-backend:8079/;
proxy_set_header X-Forwarded-For $remote_addr;
}
location /edge {
proxy_pass http://openems-edge:8080/;
proxy_set_header X-Forwarded-For $remote_addr;
}
location /ui-edge {
proxy_pass http://ui-edge:8082/;
proxy_set_header X-Forwarded-For $remote_addr;
}
location /ui-backend {
proxy_pass http://ui-backend:8082/;
proxy_set_header X-Forwarded-For $remote_addr;
}
}
}
Docker file
FROM --platform=$BUILDPLATFORM alpine:latest AS ui_builder
RUN apk update && apk upgrade
RUN apk add --no-cache \ npm \ nodejs
RUN npm install -g @angular/cli
FROM --platform=$BUILDPLATFORM ui_builder AS build_ui
ARG UI_VERSION
COPY ./ /src
WORKDIR /src/ui RUN npm install
FROM ghcr.io/linuxserver/baseimage-alpine:edge AS ui_base
RUN apk update && apk upgrade
RUN apk add --no-cache \ nginx \ openssl \ npm \ nodejs
RUN npm install -g @angular/cli
FROM ui_base
RUN mkdir -p /etc/nginx/site-templates /var/log/nginx /var/www/html/openems
COPY --from=build_ui /src/ui/ /opt/ui/src COPY tools/docker/openems-ui/root/ /
COPY tools/docker/openems-ui/nginx.conf /etc/nginx/nginx.conf
COPY --chown=root:root tools/docker/openems-ui/nginx.conf /etc/nginx/nginx.conf
VOLUME /etc/nginx VOLUME /var/log/nginx
ARG HOST ARG WEBSOCKET_PORT
ENV TYPE edge ENV REST_API_PORT 8084
EXPOSE 80 443
yml file
name: Build OpenEMS Docker Image
on: push: paths:
jobs: docker: runs-on: ubuntu-latest strategy: fail-fast: false matrix: image: [openems-edge, openems-backend, openems-ui, ui-backend, ui-edge] include:
image: ui-edge dockerfile: tools/docker/ui-edge/Dockerfile repo: manoj1210/ui-edge
steps:
name: Checkout uses: actions/checkout@v4
name: Set up QEMU uses: docker/setup-qemu-action@v3
name: Set up Docker Buildx uses: docker/setup-buildx-action@v3
name: Get cleaned branch name id: clean_name run: | REF_NAME=$(echo "${{ github.ref }}" | sed -e 's/refs\/heads\///' -e 's/refs\/tags\///' -e 's/release\/v//') echo "branch=${REF_NAME}-test" >> "$GITHUB_OUTPUT"
name: Login to Docker Hub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }}
name: Login to GitHub Container Registry uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }}
name: Extract metadata (tags, labels) for Docker id: meta uses: docker/metadata-action@v5 with: images: | ${{ matrix.repo }} labels: | org.opencontainers.image.authors=manoj1210 org.opencontainers.image.title=manoj1210 ${{ matrix.image }} org.opencontainers.image.vendor=manoj1210
name: Build and push Docker images uses: docker/build-push-action@v5 with: file: ${{ matrix.dockerfile }} platforms: linux/amd64, linux/arm64 push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }}
When I attempt to deploy this, the nginx container fails and stops with an error "nginx: [emerg] host not found in upstream "app" in /etc/nginx/nginx.conf:24". It seems like the internal name resolution doesn't work. I was having a similar problem with another project and then just tried to deploy this project as is. Has something changed in ECS since this was developed?
Full log: