i have a laravel based project that i have to host on digital ocean using docker. docker is working fine on localhost but shows 404 on server but phpmyadmin working fine on server as well which is running on 8080 port.
Here's my docker-compose.yml
version: '3' networks: laravel: services: nginx: image: nginx:stable-alpine container_name: nginx ports: - "8088:80" volumes: - ./src:/var/www/html - ./nginx/default.conf:/etc/nginx/conf.d/default.conf depends_on: - php - mysql networks: - laravel mysql: image: mysql:5.7.22 restart: unless-stopped tty: true ports: - "4306:3306" volumes: - ./mysql:/var/lib/mysql environment: MYSQL_ROOT_PASSWORD: "root" MYSQL_DATABASE: "laravel_test" MYSQL_USER: "root" MYSQL_PASSWORD: "root" SERVICE_TAGS: "dev" SERVICE_NAME: "mysql" networks: - laravel php: build: context: . dockerfile: Dockerfile container_name: php volumes: - ./src:/var/www/html ports: - "9000:9000" restart: unless-stopped networks: - laravel phpmyadmin: image: phpmyadmin restart: always ports: - 8080:80 environment: - PMA_ARBITRARY=1 links: - mysql networks: - laravel npm: image: node:18-alpine3.14 container_name: npm volumes: - ./src:/var/www/html working_dir: /var/www/html entrypoint: [ 'npm', '--no-bin-links' ] networks: - laravel composer: image: composer:latest container_name: composer volumes: - ./src:/var/www/html working_dir: /var/www/html depends_on: - php networks: - laravel Dockerfile
FROM php:8.1.0-fpm RUN docker-php-ext-install pdo pdo_mysql default.conf
server{ listen 80; index index.php index.html; server_name localhost; error_log /var/log/nginx/error.log; access_log /var/log/nginx/access.log; root /var/www/html/public; location / { try_files $uri $uri/ /index.php?$query_string; } location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass php:9000; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; } } my php file is in ./src/public/
/var/www/html/public? (4) Does/var/www/html/public/index.phpexist?/var/log/nginx/access.logor/var/log/nginx/error.logwhen you try to access it from outside. If not then you're not actually connecting to this server, something else is feeding you the 403 error. By (2) I mean, the URL with thehttps://domain.name/stripped off the front and any?query=stringand#anchorstripped off the end. Further question: by "working on localhost", do you mean you're running a client (such ascurlorwget) with a URL likehttps://localhost/src/public/yourpage.php?/var/log/nginx/access.log. im new to linux and ops side of development./src/public/yourscript"