Reverse Proxy with NGINX, Docker, Nuxt and Laravel API

I have had an issue for some time where my Nuxt SSR app cannot connect to my Laravel API.
It can connect client-side, but is unable to server-side.

They are both dockerised and I am using an nginx reverse-proxy with SSL.

This is the error I receive.

Thank you!

{
    "__v_isShallow": false,
    "__v_isRef": true,
    "_rawValue": {
        "message": "[GET] "https://local.api.website.co.uk/global-data": <no response> fetch failed",
        "statusCode": 500
    },
    "_value": {
        "message": "[GET] "https://local.api.website.co.uk/global-data": <no response> fetch failed",
        "statusCode": 500
    }
}

Nginx Reverse-Proxy

docker-compose.yml

version: '3.1'

services:
  nginx-proxy:
    image: nginxproxy/nginx-proxy
    container_name: nginx_proxy
    ports:
      - 80:80
      - 443:443
    volumes:
      - /var/run/docker.sock:/tmp/docker.sock:ro
      - ./nginx/logs:/var/log/nginx
      - ./nginx/custom_proxy_settings.conf:/etc/nginx/conf.d/custom_proxy_settings.conf
      - ./nginx/certs:/etc/nginx/certs
    restart: unless-stopped

networks:
  default:
    name: docker-proxy

Nuxt SSR App

docker-compose.yml

version: '3.3'
services:
  web:
    image: nginx:latest
    volumes:
      - .:/var/www
      - ./.docker/nginx.conf:/etc/nginx/conf.d/default.conf
    networks:
      - docker_network
      - docker_proxy
    environment:
      - VIRTUAL_HOST=local.website.co.uk
  assets:
    image: node:22
    ports:
      - 3001:3001
      - 24678:24678
    volumes:
      - .:/app
    working_dir: /app
    environment:
      HOST: 0.0.0.0
    networks:
      - docker_network
      - docker_proxy
networks:
  docker_network:
    driver: bridge
  docker_proxy:
    external:
      name: docker-proxy

nginx.conf

map $sent_http_content_type $expires {
    "text/html"                 epoch;
    "text/html; charset=utf-8"  epoch;
    default                     off;
}

server {
    listen          80;      
    server_name     127.0.0.1;   

    gzip            on;
    gzip_types      text/plain application/xml text/css application/javascript;
    gzip_min_length 1000;

    location /_nuxt/ {
        proxy_http_version           1.1;
        proxy_set_header Upgrade     $http_upgrade;
        proxy_set_header Connection  "upgrade";
        proxy_set_header Host        $host;
        proxy_cache_bypass           $http_upgrade;
        proxy_pass                   http://assets:3001;
    }

    location / {
        expires $expires;

        proxy_redirect                      off;
        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_read_timeout                  1m;
        proxy_connect_timeout               1m;
        proxy_pass                          http://assets:3001;
    }
}

Laravel API

docker-compose.yml

version: '3'
services:
  web:
    image: nginx:latest
    volumes:
      - .:/var/www
      - ./.docker/nginx/nginx.conf:/etc/nginx/conf.d/default.conf
      - ./.docker/nginx/logs:/var/log/nginx
    networks:
      - docker_network
      - docker_proxy
    environment:
      - VIRTUAL_HOST=local.api.website.co.uk
    restart: unless-stopped
  app:
    image: api-app
    container_name: api-app
    ports:
      - 9000:9000
    build:
      context: .docker/php
      dockerfile: Dockerfile
    working_dir: /var/www
    volumes:
      - .:/var/www
      - ./.docker/php/php.ini:/usr/local/etc/php/conf.d/override.ini
      - ./.docker/php/supervisord.conf:/etc/supervisor/conf.d/supervisord.conf
    networks:
      - docker_network
      - docker_proxy
    restart: unless-stopped
networks:
  docker_network:
    driver: bridge
  docker_proxy:
    external:
      name: docker-proxy

nginx.conf

server {
    listen 80;
    server_name local.api.website.co.uk

    root /var/www/public;
    index index.php index.html;

    location / {
        try_files $uri /index.php?$args;
    }

    location ~* ^.+.(css|js|jpg|jpeg|png|gif|zip|pdf|doc|docx|xls|xlsx|txt|flv|swf|vcf)$ {
        rewrite "^(.*)__d{1,10}.(css|js|jpg|jpeg|png|gif)$" $1.$2;
    }

    location ~ .php$ {
        fastcgi_split_path_info       ^(.+.php)(/.+)$;
        fastcgi_pass                  app:9000;
        fastcgi_index                 index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO       $fastcgi_path_info;
    }
}

I have tried to find the source of the issue in nginx conf or docker compose files to no avail. I haven’t found any log files for the issue.

New contributor

Edmund is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật