1

我在 nginx 反向代理后面使用 docker-compose 设置了 Invoice ninja,该代理还管理 TLS 证书。

据我从日志中可以看出,一切都初始化正确,但是当我导航到该站点时,我只能看到 500 服务器错误。

我提供了我的 docker-compose 和日志,直到下面的第一个 500 错误。

提前致谢!

码头工人-compose.yml

version: '3.7'

services:
  server:
    image: caddy:alpine
    restart: always
    environment:
      - APP_URL=http://ninja.example.de
    volumes:
      # Vhost configuration
      - ./config/caddy/Caddyfile:/etc/caddy/Caddyfile
      - ./public:/var/www/app/public
      - ./storage:/var/www/app/storage
    depends_on:
      - app
    # Run webserver nginx on port 80
    # Feel free to modify depending what port is already occupied
    ports:
      - "127.0.0.1:4301:80"
    #  - "443:443"
    networks:
      - invoiceninja

  app:
    image: invoiceninja/invoiceninja:5
    restart: always
    environment:
      - APP_URL=ninja.example.de
      - APP_KEY=base64:mykeyxzy
      - MULTI_DB_ENABLED=false
      - DB_HOST1=db
    volumes:  
      - ./public:/var/www/app/public
      - ./storage:/var/www/app/storage
    depends_on:
      - db
    networks:
      - invoiceninja

  db:
    image: mysql:5
    restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=mypassword
      - MYSQL_USER=ninja
      - MYSQL_PASSWORD=ninja
      - MYSQL_DATABASE=db-ninja-01
    volumes:  
      - ./mysql/data:/var/lib/mysql
    networks:
      - invoiceninja

 # cron:
 # cron is commented out by me

volumes:
  mysql-data:
  public:
  storage:

networks:
  invoiceninja:

码头工人日志

server_1  | {"level":"info","ts":1590774949.786359,"msg":"using provided configuration","config_file":"/etc/caddy/Caddyfile","config_adapter":"caddyfile"}
server_1  | {"level":"info","ts":1590774949.7946017,"logger":"admin","msg":"admin endpoint started","address":"tcp/localhost:2019","enforce_origin":false,"origins":["localhost:2019","[::1]:2019","127.0.0.1:2019"]}
server_1  | {"level":"info","ts":1590774949.7968726,"logger":"http","msg":"server is listening only on the HTTP port, so no automatic HTTPS will be applied to this server","server_name":"srv0","http_port":80}
server_1  | 2020/05/29 17:55:49 [INFO][cache:0xc00075e0a0] Started certificate maintenance routine
server_1  | {"level":"info","ts":1590774949.7995124,"logger":"tls","msg":"cleaned up storage units"}
server_1  | {"level":"info","ts":1590774949.799886,"msg":"autosaved config","file":"/config/caddy/autosave.json"}
server_1  | {"level":"info","ts":1590774949.799923,"msg":"serving initial configuration"}
app_1     | Configuration cache cleared!
app_1     | Configuration cached successfully!
app_1     | Route cache cleared!
app_1     | Routes cached successfully!
app_1     | Files cached successfully!
app_1     | [29-May-2020 17:55:49] NOTICE: [pool www] 'user' directive is ignored when FPM is not running as root
app_1     | [29-May-2020 17:55:49] NOTICE: [pool www] 'user' directive is ignored when FPM is not running as root
app_1     | [29-May-2020 17:55:49] NOTICE: [pool www] 'group' directive is ignored when FPM is not running as root
app_1     | [29-May-2020 17:55:49] NOTICE: [pool www] 'group' directive is ignored when FPM is not running as root
app_1     | [29-May-2020 17:55:49] NOTICE: fpm is running, pid 1
app_1     | [29-May-2020 17:55:49] NOTICE: ready to handle connections
db_1      | 2020-05-29 17:55:48+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.30-1debian10 started.
db_1      | 2020-05-29 17:55:48+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
db_1      | 2020-05-29 17:55:48+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.30-1debian10 started.
db_1      | 2020-05-29T17:55:48.703457Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
db_1      | 2020-05-29T17:55:48.708189Z 0 [Note] mysqld (mysqld 5.7.30) starting as process 1 ...
db_1      | 2020-05-29T17:55:48.714931Z 0 [Note] InnoDB: PUNCH HOLE support available
db_1      | 2020-05-29T17:55:48.714988Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
db_1      | 2020-05-29T17:55:48.714995Z 0 [Note] InnoDB: Uses event mutexes
db_1      | 2020-05-29T17:55:48.714999Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
db_1      | 2020-05-29T17:55:48.715002Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
db_1      | 2020-05-29T17:55:48.715011Z 0 [Note] InnoDB: Using Linux native AIO
db_1      | 2020-05-29T17:55:48.715701Z 0 [Note] InnoDB: Number of pools: 1
db_1      | 2020-05-29T17:55:48.716017Z 0 [Note] InnoDB: Using CPU crc32 instructions
db_1      | 2020-05-29T17:55:48.722484Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
db_1      | 2020-05-29T17:55:48.741778Z 0 [Note] InnoDB: Completed initialization of buffer pool
db_1      | 2020-05-29T17:55:48.747111Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
db_1      | 2020-05-29T17:55:48.763090Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
db_1      | 2020-05-29T17:55:48.798980Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
db_1      | 2020-05-29T17:55:48.799233Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
db_1      | 2020-05-29T17:55:48.832312Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
db_1      | 2020-05-29T17:55:48.834307Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
db_1      | 2020-05-29T17:55:48.834434Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
db_1      | 2020-05-29T17:55:48.835099Z 0 [Note] InnoDB: Waiting for purge to start
db_1      | 2020-05-29T17:55:48.885461Z 0 [Note] InnoDB: 5.7.30 started; log sequence number 12488420
db_1      | 2020-05-29T17:55:48.886497Z 0 [Note] Plugin 'FEDERATED' is disabled.
db_1      | 2020-05-29T17:55:48.897039Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
db_1      | 2020-05-29T17:55:48.906339Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
db_1      | 2020-05-29T17:55:48.906387Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.
db_1      | 2020-05-29T17:55:48.907291Z 0 [Warning] CA certificate ca.pem is self signed.
db_1      | 2020-05-29T17:55:48.907356Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.
db_1      | 2020-05-29T17:55:48.908141Z 0 [Note] InnoDB: Buffer pool(s) load completed at 200529 17:55:48
db_1      | 2020-05-29T17:55:48.909168Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
db_1      | 2020-05-29T17:55:48.909863Z 0 [Note] IPv6 is available.
db_1      | 2020-05-29T17:55:48.909911Z 0 [Note]   - '::' resolves to '::';
db_1      | 2020-05-29T17:55:48.909952Z 0 [Note] Server socket created on IP: '::'.
db_1      | 2020-05-29T17:55:48.914971Z 0 [Warning] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
db_1      | 2020-05-29T17:55:48.932266Z 0 [Note] Event Scheduler: Loaded 0 events
db_1      | 2020-05-29T17:55:48.932616Z 0 [Note] mysqld: ready for connections.
db_1      | Version: '5.7.30'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server (GPL)
app_1     | 192.168.48.5 -  29/May/2020:17:59:07 +0000 "GET /index.php" 500
4

1 回答 1

2

发生此错误的原因是应用程序无法正确确定传递的应用程序密钥APP_KEY。似乎应用程序缓存有点不愿意刷新 - 这只是 docker 容器中的问题,而不是没有 docker 的自托管选项。

我将更新推送到latestand5标签。所以首先,请更新您的图像。这修复了一些权限以获得对某些缓存文件夹的正确写入权限。

然后在您的 docker-compose 设置开始后,请运行

docker-compose exec app php artisan config:cache

几次并刷新您的页面。刷新缓存需要一些时间和几次调用。然后错误消息更改为SQLSTATE[42S02]: Base table or view not found:这是一个已知问题,但可以通过导航修复(现在)/setup,然后将运行正确的迁移。

于 2020-06-01T21:37:07.787 回答