Doug Fir
Doug Fir

Reputation: 21292

map nginx conf within docker to correct location

I've been struggling to make changes to my docker app. After a lot of trial and error it looks what I thought was my nginx conf file might not actually be my nginx conf file.

I have determined this because I tried removing it entirely and my app runs the same with docker.

It looks like changes I make to my nginx service via the app.conf file have been having no impact on the rest of my app.

I am trying to understand if my volume mapping is correct. Here's my docker compose:

version: "3.5"
services:
  collabora:
    image: collabora/code
    container_name: collabora
    restart: always
    cap_add:
      - MKNOD
    environment:
      - "extra_params=--o:ssl.enable=false --o:ssl.termination=true"
      - domain=mydomain\.com
      - dictionaries=en_US
    ports:
      - "9980:9980"
    volumes:
      - ./appdata/collabora:/config    
  nginx:
    image: nginx:1.15-alpine
    restart: unless-stopped
    depends_on:
      - certbot   
      - collabora 
    volumes:
#      - ./data/nginx:/etc/nginx/conf.d
      - ./data/nginx:/etc/nginx
      - ./data/certbot/conf:/etc/letsencrypt
      - ./data/certbot/www:/var/www/certbot
    ports:
      - "80:80"
      - "443:443"
    command: "/bin/sh -c 'while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g \"daemon off;\"'"
  certbot:
    image: certbot/certbot
    restart: unless-stopped
    volumes:
      - ./data/certbot/conf:/etc/letsencrypt
      - ./data/certbot/www:/var/www/certbot
    entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"

My projects directory is:

/my_project

And then my app.conf has various nginx settings

server {
    listen 80;
    server_name example.com www.example.com;
    server_tokens off;

    location /.well-known/acme-challenge/ {
        root /var/www/certbot;
    }

    location / {
        return 301 https://$host$request_uri;
    }
}  ... more settings below

Assuming I'm correct that my app.conf file is not being used, how can I correctly map app.conf on local to the correct place in the nginx container?

Upvotes: 1

Views: 2127

Answers (1)

XDarktemiX
XDarktemiX

Reputation: 34

nginx conf directory is

/etc/nginx/nginx.conf

This File has an include of all of contento from

/etc/nginx/conf.d/*

You can verify your nginx.conf in use executing a ps -ef | grep nginx on your container. Verify your default.conf. Anyway, in your compose you must have:

volumes:
- ./data/nginx:/etc/nginx/conf.d

Try with absolute path

Regards

Upvotes: 1

Related Questions