Laravel Horizon + Nginx Proxy Manager doesn't serve static files on server, but works on local

210 views Asked by At

I am working on deploying my project on self host gitlab with portainer to handle redeploy on webhook trigger, now i have this configuration of docker-compose which starts the api of the project which based on laravel, the problem is all the requests to static file are getting 502, nginx error and access logs doesn't show anything apart from that it was forwarded to proxy upstream, i used basic laravel nginx config from docs, you can check the errors on network tab on this website, https://api.dev.rmshare.ru/horizon

api:
 volumes:
  - 'storage:/var/www/html/storage/app/public'
  - 'vendor:/var/www/html/public/vendor'

nginx-proxy-manager:
 image: 'jc21/nginx-proxy-manager:latest'
 volumes:
  - 'storage:/var/www/html/public/storage'
  - 'vendor:/var/www/html/public/vendor'
  - './docker/nginx/data:/data'
  - './docker/nginx/letsencrypt:/etc/letsencrypt'

volumes:
 storage:
  driver: local
 vendor:
  driver: local

Here is the gitlab ci, it works perfectly and deploys the containers on specific runner

stages:
- build
- deploy

build_image:
  stage: build
  image: docker
  services:
    - docker:dind
  script:
    - echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER $CI_REGISTRY --password-stdin
    - docker build -t $CI_REGISTRY_IMAGE .
    - docker push $CI_REGISTRY_IMAGE

deploy_staging:
  stage: deploy
  script:
    - echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER $CI_REGISTRY --password-stdin
    - docker pull $CI_REGISTRY_IMAGE
    - curl -X POST http://portainer.gitlab.rmshare.ru/api/stacks/webhooks/36a89ae7-d9ef-408d-8ff4-7a1ffeb36924
  environment:
    name: staging
    url: https://api.dev.rmshare.ru
  tags:
    - staging
  only:
    - staging

I inserted short version to make it more detailed about issue

Any clue will be appriciated, thanks in advance

have tried on local just by doing docker compose up -d it work perfectly, also one more thing is i can't browse the volume with portainer

1

There are 1 answers

1
Hadi Sharghi On

Did you publish horizon assets? before running php artisan horizon command? Assets are going to load from https://api.dev.rmshare.ru/vendor/horizon/ url which points to public directory. artisan horizon:publish will copy all the assets into public/vendor/horizon directory.