mybb / docker

The official Dockerfile for the MyBB forum software.

Home Page:https://mybb.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Doesn't actually work

Southclaws opened this issue · comments

Ran the example, also ran a slightly more filled-in config for a production deployment, fpm seems to be misconfigured (I'm not a PHP user so I'm only guessing).

Once the container is up, hitting the fpm endpoint just results in curl: (56) Recv failure: Connection reset by peer, did this from inside the container to rule out any possible Docker network issues.

Here's a configuration to reproduce, just run this and curl localhost:9000 or exec into the container and do the same:

version: "3.5"

networks:
    default:
        external:
            name: gateway
    database:
        driver: bridge
        internal: true

services:
    mybb:
        image: mybb/mybb:latest
        volumes:
            - ${DATA_DIR}/burgershot/mybb:/var/www/html
        networks:
            - default
            - database
        labels:
            - traefik.docker.network=gateway
            - traefik.frontend.rule=Host:example.com
            - traefik.frontend.headers.SSLRedirect=false
            - traefik.port=9000

    postgresql:
        image: postgres:10.4
        environment:
            POSTGRES_DB: mybb
            POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
            POSTGRES_USER: mybb
        networks:
            - database
        volumes:
            - ${DATA_DIR}/mybb/postgres/data:/var/lib/postgresql/data

You don't have any kind of reverse proxy capable of handling FastCGI requests from the looks of it. PHP-FPM does not speak HTTP in the way that you're thinking.

I noticed that you're using Traefik, which currently does not speak FastCGI.

traefik/traefik#753

I realised this in the morning! I'm not used to PHP things (as you can probably tell) I'm used to standard HTTP servers!

So I stuck an nginx in there like the example which serves the statics directory but it just displays the default nginx landing page. Not sure if the example is wrong or if there's some extra config nginx needs.

You need to mount a configuration file into the nginx container, here's one you can use - it assumes your MyBB container will resolve the the hostname of mybb in the container stack. You will then need to bind-mount cross-containers the /var/www/html directories so that both nginx and PHP-FPM can see them - or none of your static files will work. Make sure you open port 80 on the nginx container too.

upstream mybb {
    server mybb:9000 weight=5;
}

server {
    listen 80;
 
    root /var/www/html;
    index index.html index.php;

    if ( $request_method !~ ^(GET|POST)$ ) {
        return 405;
    }

    location = /favicon.ico { log_not_found off; access_log off; }
    location = /robots.txt  { log_not_found off; access_log off; }
 
    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ inc/ {
        internal;
    }

    location ~ ^/(images|cache|jscripts|uploads)/ {
        access_log off;
    }

    location ~* /\.(?!well-known\/) {
        deny all;
    }

    location ~* (?:\.(?:bak|conf|dist|fla|in[ci]|log|psd|sh|sql|sw[op])|~)$ {
        deny all;
    }
 
    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass mybb;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }
}

Thanks! After some configuration it's all working now.