user56683
user56683

Reputation: 47

nginx/docker routing config

I have a digital ocean droplet. In the root of it are the following files

apps/
 -main/
   -index.html
nginx.conf
docker-compose.yml

My docker-compose.yml file has the following

version: '3'

networks:
  proxy:
    external: true
  internal:
    external: false
services:
  traefik:
    image: traefik:alpine
    ports:
      - "8080:8080"
      - "80:80"
      - "443:443"
    restart: always
    labels:
      - logLevel="DEBUG"
      - "traefik.backend=monitor"
      - "traefik.frontend.rule=Host:monitor.domain.com"
      - "traefik.port=8080"
      - "traefik.frontend.entryPoints=http,https"
      - "traefik.enable=true"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock"
      - "./traefik.toml:/traefik.toml"
      - "./acme.json:/acme.json"
    expose:
      - "8080"
    networks:
      - internal
      - proxy
  custom-badge:
    image: user/app
    environment:
      PORT: 3000
    ports:
      - "3000:3000"
    labels:
      - traefik.enabled=true
      - traefik.backend=app
      - traefik.frontend.rule=Host:app.domain.com
      - traefik.docker.network=proxy
      - traefik.port=3000
    networks:
      - internal
      - proxy
  server:
    image: nginx:alpine
    labels:
      - traefik.enabled=true
      - traefik.backend=
      - traefik.frontend.rule=Host:domain.com
      - traefik.docker.network=proxy
      - traefik.port=80
    volumes:
      - "./apps:/etc/nginx/html:ro"
      - "./nginx.conf:/etc/nginx/nginx.conf:ro"
    command: [nginx-debug, '-g', 'daemon off;']
    depends_on:
      - traefik

and my nginx.conf

events {
  worker_connections  1024;  ## Default: 1024
}

http {
server {
    listen          80;
    server_name     domain.com www.domain.com;
    location / {
        root  /etc/nginx/html/main;
        proxy_pass  domain.com:8080/;
    }
}
}

Problem is, when I run docker-compose up everything starts up and I can see all 3 containers started but when I go to domain.com I am not seeing my index.html file. What have I done wrong ?

The other domains work fine: app.domain.com & monitor.domain.com which makes me think it must be something wrong with the nginx config and what files need to be served.

Upvotes: 0

Views: 328

Answers (1)

Miq
Miq

Reputation: 4289

You have a loop - remove proxy_pass. Nginx should serve the data from root folder, not proxy the requests to another service.

Upvotes: 1

Related Questions