Learn about Centmin Mod LEMP Stack today
Become a Member

How to change nginx config to launch docker app in browser?

Discussion in 'Other Web Apps usage' started by redbird, Jan 31, 2026.

  1. redbird

    redbird Member

    109
    15
    18
    Aug 28, 2015
    Web
    Ratings:
    +29
    Local Time:
    12:20 AM
    Hi all,

    I'm trying to set up an app that runs as docker image. Here is its config:


    Code:
    services:
      db:
        restart: always
        image: postgres:17
        volumes:
          - /var/fider/pg_data:/var/lib/postgresql/data
        environment:
          POSTGRES_USER: fider
          POSTGRES_PASSWORD: s0m3g00dp4ssw0rd
      app:
        restart: always
        image: getfider/fider:stable
        ports:
          - "80:3000"
        environment:
          # Public Host Name
          BASE_URL: http://localhost
    
          # Connection string to the PostgreSQL database
          DATABASE_URL: postgres://fider:s0m3g00dp4ssw0rd@db:5432/fider?sslmode=disable
    
          # Generate a secure secret, for example using https://jwtsecrets.com
          JWT_SECRET: VERY_STRONG_SECRET_SHOULD_BE_USED_HERE
    
          # From which account e-mails will be sent
          EMAIL_NOREPLY: noreply@yourdomain.com
    
          ###
          # EMAIL
          # Either EMAIL_MAILGUN_* or EMAIL_SMTP_* or EMAIL_AWSSES_* is required
          ###
    
          # EMAIL_MAILGUN_API: key-yourkeygoeshere
          # EMAIL_MAILGUN_DOMAIN: yourdomain.com
          # EMAIL_MAILGUN_REGION: US
    
          # EMAIL_SMTP_HOST: smtp.yourdomain.com
          # EMAIL_SMTP_PORT: 587
          # EMAIL_SMTP_USERNAME: user@yourdomain.com
          # EMAIL_SMTP_PASSWORD: s0m3p4ssw0rd
          # EMAIL_SMTP_ENABLE_STARTTLS: 'true'
    
          # EMAIL_AWSSES_REGION: us-east-1
          # EMAIL_AWSSES_ACCESS_KEY_ID: youraccesskeygoeshere
          # EMAIL_AWSSES_SECRET_ACCESS_KEY: yoursecretkeygoeshere
    Here is the docs for reference: Hosting on Docker | Fider Docs

    So it listens to port 80 and then runs http on port 3000.

    I tried adding a proxy like this to vhost's nginx config but it returns bad gateway 502 error:
    Code:
    location / {
            proxy_pass http://localhost:3000;
      }
    
    How do I properly set it up?

    Trying to figure out how docker works.

    Thanks
    RB



    • CentOS Version: AlmaLinux 8
    • Centmin Mod Version Installed: 140.00beta01
     
  2. eva2000

    eva2000 Administrator Staff Member

    59,279
    12,508
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +19,140
    Local Time:
    12:20 AM
    Nginx 1.31.x
    MariaDB 10.x/11.4+/12.3+
    Centmin Mod is provided as is, so learning how to use Docker with it is left up to users. Users are free to help each other out here :)

    Don't use 80:3000 as Docker trying to listen on Nginx's port 80 which is already taken. Change your Docker Compose port mapping from 80:3000 to 127.0.0.1:3000:3000 and update your nginx proxy_pass to http://127.0.0.1:3000; with proper proxy headers (Host, X-Real-IP, X-Forwarded-For, X-Forwarded-Proto)

    Code (Text):
    # Required headers for reverse proxy
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Port $server_port;
    
    # Connection handling
    proxy_http_version 1.1;
    proxy_set_header Connection "";
    
    # Timeouts
    proxy_connect_timeout 60s;
    proxy_send_timeout 60s;
    proxy_read_timeout 60s;
    


    Also you may need to configure CSF Firewall properly for Docker too. On developmental Centmin Mod 141.00beta01 which is for EL10 OS development, I did add an addon/docker.sh script https://github.com/centminmod/centminmod/blob/141.00beta01/addons/docker.sh which makes it easier if you grab the script and only run csf-setup command, should help but depends on how you install and configured Docker so mileage my vary

    can run csf-setup and then csf-test to check
    Code (Text):
    cd /usr/local/src/centminmod/addons
    curl -sL https://github.com/centminmod/centminmod/raw/refs/heads/141.00beta01/addons/docker.sh -o docker.sh
    chmod +x docker.sh
    ./docker.sh csf-setup
    ./docker.sh csf-test
    


    edit: I started writing some more detail guides first on Centmin Mod GitHub repo, you can check them out at https://github.com/centminmod/centminmod/tree/141.00beta01/guides. One is for Centmin Mod Nginx proxy with Docker
     
    Last edited: Jan 31, 2026
  3. redbird

    redbird Member

    109
    15
    18
    Aug 28, 2015
    Web
    Ratings:
    +29
    Local Time:
    12:20 AM
    Thank you George. You are the best as always. Will try it and will study the guides as well.

     
  4. redbird

    redbird Member

    109
    15
    18
    Aug 28, 2015
    Web
    Ratings:
    +29
    Local Time:
    12:20 AM
    @eva2000 Ok, here is an update. I tried to mess with this for several hours but still no luck (

    So on a new server with Almalinux 9 and centminmode 140b I followed your guide to the dot to install docker compose and then setup fider (also using your guide) I couldn't even get to the previous result where fider would launch on a custom port 8080. That's even before messing with nginx conf settings.

    So after quite some time messing with different settings I decided to completely remove docker and install it a normal way:

    Code:
    dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
    install docker-ce docker-ce-cli containerd.io
    systemctl start docker.service
    systemctl enable docker.service
    Then I set up fider and was finally able to launch it without nginx via port 8080 (which makes me think that there is something wrong with your docker.sh addon as it wouldn't even let me do that. )

    After that trying to edit nginx ssl.conf and docker-compose.yml following your instructions in the guide to try to make it work via https and without any ports all it does returns 502 bad gateway (((

    I'm totally lost

    yml with sensitive data removed:
    Code:
    services:
      db:
        restart: always
        image: postgres:17
        volumes:
          - /var/fider/pg_data:/var/lib/postgresql/data
        environment:
          POSTGRES_USER: fider
          POSTGRES_PASSWORD: xxxxx
      app:
        restart: always
        image: getfider/fider:stable
        ports:
          - "127.0.0.1:3000:3000"
        environment:
          # Public Host Name
          BASE_URL: https://vote.feedgi.com
    
          # Connection string to the PostgreSQL database
          DATABASE_URL: postgres://fider:xxxxx@db:5432/fider?sslmode=disable
    
          # Generate a secure secret, for example using https://jwtsecrets.com
          JWT_SECRET: xxxxx
    
          # From which account e-mails will be sent
          EMAIL_NOREPLY: xxxxx
    
          ###
          # EMAIL
          # Either EMAIL_MAILGUN_* or EMAIL_SMTP_* or EMAIL_AWSSES_* is required
          ###
    
          # EMAIL_MAILGUN_API: key-yourkeygoeshere
          # EMAIL_MAILGUN_DOMAIN: yourdomain.com
          # EMAIL_MAILGUN_REGION: US
    
          # EMAIL_SMTP_HOST: smtp.yourdomain.com
          # EMAIL_SMTP_PORT: 587
          # EMAIL_SMTP_USERNAME: user@yourdomain.com
          # EMAIL_SMTP_PASSWORD: s0m3p4ssw0rd
          # EMAIL_SMTP_ENABLE_STARTTLS: 'true'
    
          EMAIL_AWSSES_REGION: us-east-1
          EMAIL_AWSSES_ACCESS_KEY_ID: xxxxx
          EMAIL_AWSSES_SECRET_ACCESS_KEY: xxxxx
    
    ssl.conf file:
    Code:
    # Upstream for Fider Docker container
    upstream fider_backend {
        server 127.0.0.1:3000;
        keepalive 32;
    }
    
    server {
        listen 443 ssl http2;
        server_name vote.feedgi.com;
    
        # SSL certificates (managed by Centmin Mod/acme.sh)
        ssl_certificate /usr/local/nginx/conf/ssl/vote.feedgi.com/vote.feedgi.com.crt;
        ssl_certificate_key /usr/local/nginx/conf/ssl/vote.feedgi.com/vote.feedgi.com.key;
    
        # SSL configuration (Centmin Mod defaults)
        include /usr/local/nginx/conf/ssl_include.conf;
    
        # Logging
        access_log /home/nginx/domains/vote.feedgi.com/log/access.log combined buffer=256k flush=5m;
        error_log /home/nginx/domains/vote.feedgi.com/log/error.log;
    
        # Security headers
        add_header X-Frame-Options "SAMEORIGIN" always;
        add_header X-Content-Type-Options "nosniff" always;
        add_header X-XSS-Protection "1; mode=block" always;
        add_header Referrer-Policy "strict-origin-when-cross-origin" always;
    
        location / {
            proxy_pass http://fider_backend;
    
            # Essential proxy headers
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header X-Forwarded-Host $host;
            proxy_set_header X-Forwarded-Port $server_port;
    
            # WebSocket support (Fider uses WebSockets for real-time updates)
           # proxy_http_version 1.1;
           # proxy_set_header Upgrade $http_upgrade;
           # proxy_set_header Connection $connection_upgrade;
    
            # Timeouts
            proxy_connect_timeout 60s;
            proxy_send_timeout 60s;
            proxy_read_timeout 60s;
    
            # Buffering (adjust based on application needs)
            proxy_buffering on;
            proxy_buffer_size 4k;
            proxy_buffers 8 4k;
            proxy_busy_buffers_size 8k;
        }
    # Static assets caching (if applicable)
        location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2)$ {
            proxy_pass http://fider_backend;
            proxy_set_header Host $host;
            proxy_cache_valid 200 30d;
            expires 30d;
            add_header Cache-Control "public, immutable";
        }
    }
    
    # HTTP to HTTPS redirect
    server {
        listen 80;
        server_name vote.feedgi.com;
        return 301 https://$server_name$request_uri;
    }
    
    Here is vhost nginx error log snippet:
    Code:
    2026/02/05 00:55:15 [error] 69423#69423: *1 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 172.64.200.88, server: vote.feedgi.com, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8080/", host: "vote.feedgi.com"
    2026/02/05 00:55:16 [error] 69422#69422: *5 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 172.64.198.222, server: vote.feedgi.com, request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:8080/favicon.ico", host: "vote.feedgi.com", referrer: "http://vote.feedgi.com/"
    2026/02/05 00:55:16 [error] 69422#69422: *5 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 172.64.198.222, server: vote.feedgi.com, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8080/", host: "vote.feedgi.com"
    2026/02/05 00:55:16 [error] 69423#69423: *1 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 172.64.200.88, server: vote.feedgi.com, request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:8080/favicon.ico", host: "vote.feedgi.com", referrer: "http://vote.feedgi.com/"
    2026/02/05 00:57:53 [error] 69560#69560: *2 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 172.64.200.89, server: vote.feedgi.com, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "vote.feedgi.com"
    2026/02/05 00:57:54 [error] 69560#69560: *2 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 172.64.200.89, server: vote.feedgi.com, request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:3000/favicon.ico", host: "vote.feedgi.com", referrer: "http://vote.feedgi.com/"
    2026/02/05 00:57:55 [error] 69560#69560: *2 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 172.64.200.89, server: vote.feedgi.com, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "vote.feedgi.com"
    2026/02/05 00:57:55 [error] 69560#69560: *2 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 172.64.200.89, server: vote.feedgi.com, request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:3000/favicon.ico", host: "vote.feedgi.com", referrer: "http://vote.feedgi.com/"
    
    Note: domain is hosted at Cloudflare. I tested both ways: with proxy on or off.
     
    Last edited: Feb 5, 2026
  5. redbird

    redbird Member

    109
    15
    18
    Aug 28, 2015
    Web
    Ratings:
    +29
    Local Time:
    12:20 AM
    It's seems like starting everything from scratch (by removing even docker completely) and then following your guide precisely step by step everything finally worked ).
    The problem in the previous post was related to csf step not being setup correctly.