Help with nginx conf for mealie

Hello, I am trying to set up a Docker container for SWAG and Mealie

I have both services running fine but the SWAG Nginx config seems to be broken. If I navigate to mealie[.]DOMAIN[.]com it just redirects me to the “Welcome to your SWAG” page

I am using Cloudflare DNS and have disabled Cloudflare proxy and also tried setting SSL mode t o Off. The Welcome page was working with proxy enabled and SSL mode set to Full. But to debug I tried turning them off. I also have my A record set to @ → server IP and a CNAME for * → DOMAIN[.]com

I will try posting my configs below. Note: I had to replace all of the URLs with a [.] but my actual files don’t have the []. My .env file also has all of my secrets configured.

SWAG config:

  swag:
    image: lscr[.]io/linuxserver/swag:latest
    container_name: swag
    cap_add:
      - NET_ADMIN
    env_file:
      - ./.env
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=America/Los_Angeles
      - URL=DOMAIN[.]com
      - SUBDOMAINS=wildcard
      # ZeroSSL Config
      - CERTPROVIDER=zerossl
      - EMAIL=XXXX
      # Cloudflare Config
      - VALIDATION=dns
      - DNSPLUGIN=cloudflare
      - CF_ZONE_ID=XXXX
      - CF_ACCOUNT_ID=XXXX
    volumes:
      - /etc/config/swag:/config
      - /home/aptalca/appdata/swag:/config
    ports:
      - 443:443
      - 80:80
    restart: unless-stopped

Mealie config:

  mealie:
    image: ghcr[.]io/mealie-recipes/mealie:v1.12.0 # 
    container_name: mealie
    restart: always
    ports:
        - "9925:9000" # 
    deploy:
      resources:
        limits:
          memory: 500M # 
    volumes:
      - mealie-data:/app/data/
    env_file:
      - ./.env
    environment:
      # Set Backend ENV Variables Here
      ALLOW_SIGNUP: "false"
      PUID: 1000
      PGID: 1000
      TZ: America/Los_Angeles
      MAX_WORKERS: 1
      WEB_CONCURRENCY: 1
      BASE_URL: https://mealie[.]DOMAIN[.]com
      # Database Settings
      DB_ENGINE: postgres
      POSTGRES_USER: mealie
      POSTGRES_SERVER: postgres
      POSTGRES_PORT: 5432
      POSTGRES_DB: mealie
      # Security Settings
      SECURITY_MAX_LOGIN_ATTEMPTS: 5
      SECURITY_USER_LOCKOUT_TIME: 1
    depends_on:
      postgres:
        condition: service_healthy

mealie.subdomain.conf

server {
    listen 443 ssl;
    listen [::]:443 ssl;

    server_name mealie.*;

    include /config/nginx/ssl.conf;

    client_max_body_size 0;
    location / {
        include /config/nginx/proxy.conf;
        include /config/nginx/resolver.conf;
        set $upstream_app mealie;
        set $upstream_port 9000;
        set $upstream_proto http;
        proxy_pass $upstream_proto://$upstream_app:$upstream_port;

    }
}

Testing the proxy_pass also appears to be working

$ sudo docker exec swag curl http://mealie:9000
<html lang="en" data-n-head="%7B%22lang%22:%7B%221%22:%22en%22%7D%7D">
...
</html>

If I hit my server’s IP directly, I can get to the Mealie login window
IPADDR:9925/login/

And if I try https://DOMAIN[.]com the Welcome page shows with correct SSL cert but https://mealie[.]DOMAIN[.]com also shows the Welcome page

SWAG logs

dns validation via cloudflare plugin is selected
Certificate exists; parameters unchanged; starting nginx
The cert does not expire within the next day. Letting the cron script handle the renewal attempts overnight (2:08am).
[custom-init] No custom files found, skipping...
[ls.io-init] done.
Server ready

mealie logs
shows correct log when accessing using the IP. No logs show up when using mealie[.]DOMAIN[.]com

INFO     2024-09-30T21:18:23 - [127.0.0.1:40600] 200 OK "GET /api/app/about HTTP/1.1"
INFO     2024-09-30T21:18:23 - [67.180.157.176:62511] 200 OK "GET /api/app/about HTTP/1.1"
INFO     2024-09-30T21:18:23 - [67.180.157.176:62510] 200 OK "GET /api/app/about/startup-info HTTP/1.1"

Thanks in advance all! I tried my best to read all documents and do troubleshooting but I’m really stuck…!

Ok so… I fixed it!!!

I did some more troubleshooting and saw that my nginx config was not being copied into the Docker container using this command

sudo docker exec swag ls /config/nginx/proxy-confs | grep mealie

I re-read my Docker compose file…
And because I was following along with the Cloudflare DNS setup guide and the regular SWAG setup guide…
I didn’t realize that they had the same SWAG volume twice!

    volumes:
      - /etc/config/swag:/config
      - /home/aptalca/appdata/swag:/config

So I fixed the volumes

    volumes:
      - /etc/config/swag:/config

And re-created my containers and volumes just to be safe

docker compose down
docker compose down -v
docker compose up --build -d

Re-configured Cloudflare and my nginx proxy and bam it worked!
Of course my browser was still caching the Welcome page so I tested incognito and all is well now!!!

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.