我有一个Laravel应用程序,并且能够将这些配置文件安装到docker上,而我已部署到eb,但始终收到错误502。请问我是否还有其他信息。非常感谢。
这是我的配置文件:
docker-compose.yml
version: '3'
services:
php:
build:
context: .
dockerfile: Dockerfile
image: php
depends_on:
- mysql
- redis
volumes:
- ./:/var/www
networks:
- app-network
mysql:
image: mysql:8
command: --default-authentication-plugin=mysql_native_password
ports:
- "3306:3306"
environment:
- MYSQL_DATABASE=app
- MYSQL_ROOT_PASSWORD=password
- MYSQL_USER=app
- MYSQL_PASSWORD=password
volumes:
- db-data:/var/lib/mysql
networks:
- app-network
nginx:
image: nginx:alpine
ports:
- "80:80"
- "443:443"
volumes:
- ./docker/default.conf:/etc/nginx/conf.d/default.conf
- ./:/var/www
depends_on:
- php
networks:
- app-network
redis:
image: redis:alpine
ports:
- "6379:6379"
networks:
- app-network
volumes:
db-data:
#Docker Networks
networks:
app-network:
driver: bridge
Dockerfile
FROM php:7.2-fpm
ARG envfile
# Copy source code
RUN rm -rf /var/www/*
ADD . /var/www/
# Setup laravel
WORKDIR /var/www
RUN apt-get update && apt-get install -y \
git \
libzip-dev \
zip \
unzip \
cron \
sed
RUN docker-php-ext-configure zip --with-libzip
RUN docker-php-ext-install pdo_mysql zip
RUN docker-php-ext-install pcntl
RUN curl --silent --show-error https://getcomposer.org/installer | php && \
mv composer.phar /usr/local/bin/composer
## Configure nginx
RUN rm -rf /var/www/.env && \
composer install --no-dev --no-interaction --prefer-dist --optimize-autoloader && \
touch /var/log/cron.log && \
chown www-data:www-data /var/log/cron.log && \
echo '* * * * * www-data php /var/www/artisan schedule:run >> /var/log/cron.log 2>&1' > /etc/cron.d/laravel-cron && \
chmod 0644 /etc/cron.d/laravel-cron && \
touch /etc/cron.d/laravel-cron && \
chown -R www-data:www-data /var/www/ && \
chown -R www-data:www-data /var/www/storage && \
chown -R root:www-data /var/www/storage/logs && \
chmod -R 775 /var/www/storage && \
chmod -R 775 /var/www/bootstrap/cache && \
crontab /etc/cron.d/laravel-cron
# Expose port 9000 and start php-fpm server
EXPOSE 9000
CMD ["php-fpm"]
/docker/default.conf
server {
listen 0.0.0.0:80;
index index.php index.html index.htm;
root /var/www/public; # default Laravel's entry point for all requests
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
location / {
# try to serve file directly, fallback to index.php
try_files $uri /index.php?$args;
}
location ~ \.php$ {
fastcgi_index index.php;
fastcgi_pass php:9000; # address of a fastCGI server
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
include fastcgi_params;
}
}
设置我的ec2 Nginx错误日志文件
2019/09/15 05:21:18 [error] 4445#0: *9 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 202.184.195.155, server: , request: "GET /favicon.ico HTTP/1.1", upstream: "http://172.17.0.3:9000/favicon.ico", host: "xxx.riaxasvw2y.ap-southeast-1.elasticbeanstalk.com", referrer: "http://xxx.riaxasvw2y.ap-southeast-1.elasticbeanstalk.com/"
[ec2-user@ip-172-31-43-158 ~]$ cat /etc/nginx/nginx.conf