Laravel 为nuxt应用程序设置docker+;nuxt admin+;应用程序编程接口
我有一个Laravel 为nuxt应用程序设置docker+;nuxt admin+;应用程序编程接口,laravel,docker,nuxt.js,Laravel,Docker,Nuxt.js,我有一个nuxt.js应用程序,带有laravelapi。一切都在docker中运行。你可以在这里检查我的配置。Nuxt应用程序是/client文件夹和/api中的laravel api docker-compose.yml version: '3' ######### Services ################################### services: # Server container nginx: build: context: d
nuxt.js
应用程序,带有laravel
api。一切都在docker
中运行。你可以在这里检查我的配置。Nuxt应用程序是/client
文件夹和/api
中的laravel api
docker-compose.yml
version: '3'
######### Services ###################################
services:
# Server container
nginx:
build:
context: docker/nginx
dockerfile: Dockerfile
volumes:
- ./:/var/www
- ./docker/nginx/logs:/var/log/nginx
ports:
# Nuxt port
- 80:80
# Laravel port
- 8081:81
links:
- node
- php-fpm
# PHP FastCGI Process Manager container
php-fpm:
build:
context: docker/php-fpm
dockerfile: Dockerfile
volumes:
- ./api:/var/www/api
environment:
# If you down want to use xDebug, set remote_enable=0
XDEBUG_CONFIG: "remote_enable=1"
PHP_IDE_CONFIG: "serverName=Docker"
links:
- postgres
- redis
expose:
- 81
labels:
traefik.frontend.rule: PathPrefixStrip:/api
traefik.port: 81
# Supervisor container (schedule and queue runner)
supervisor:
build:
context: docker/supervisor
dockerfile: Dockerfile
volumes:
- ./:/var/www/
- ./docker/supervisor/conf.d:/etc/supervisor/conf.d
- ./docker/supervisor/logs:/var/log
links:
- postgres
- redis
# Node container
node:
build:
context: docker/node
dockerfile: Dockerfile
volumes:
- ./client:/var/www/client
expose:
- 80
environment:
NUXT_HOST: 0.0.0.0
API_URL: http://nginx:80/api/
CLIENT_URL: http://localhost:80
GOOGLE_MAPS_API_KEY:
labels:
traefik.frontend.rule: PathPrefixStrip:/
traefik.port: 80
# PostgreSQL database container
postgres:
build:
context: docker/postgres
dockerfile: Dockerfile
volumes:
# Database volume
- database:/var/lib/postgresql/data
# Temp volume to allow using dumps
- ./docker/postgres/dumps/:/tmp/
ports:
- 5432:5432
environment:
- LC_ALL=C.UTF-8
- POSTGRES_DB=app
- POSTGRES_USER=app
- POSTGRES_PASSWORD=app
# Redis container
redis:
build:
context: docker/redis
dockerfile: Dockerfile
volumes:
- redis:/data
- ./docker/redis/redis.conf:/data/redis.conf
ports:
- 6379:6379
# Node command line container
node-cli:
build:
context: docker/node-cli
dockerfile: Dockerfile
volumes:
- ./client:/var/www/client
tty: true
# PHP Command line container
php-cli:
build:
context: docker/php-cli
dockerfile: Dockerfile
volumes:
- ./api:/var/www/api
environment:
# If you down want to use xDebug, set remote_enable=0
XDEBUG_CONFIG: "remote_enable=1"
PHP_IDE_CONFIG: "serverName=Docker"
links:
- postgres
- redis
tty: true
proxy:
build:
context: docker/php-cli
dockerfile: Dockerfile
command: --docker
ports:
- "80:80"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
elasticsearch:
build:
context: docker/elasticsearch
dockerfile: Dockerfile
volumes:
- ./docker/elasticsearch/data:/usr/share/elasticsearch/data
environment:
- node.name=elasticsearch
- discovery.seed_hosts=elasticsearch
- cluster.initial_master_nodes=elasticsearch
- cluster.name=docker-cluster
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
ports:
- 9200:9200
######### Volumes ###################################
volumes:
database:
driver: local
redis:
driver: local
docker/nginx/default.conf
#--------------------------------------------------------
# Nuxt.JS server configuration
#--------------------------------------------------------
map $sent_http_content_type $expires {
"text/html" epoch;
"text/html; charset=utf-8" epoch;
default off;
}
server {
listen 80;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
charset utf-8;
gzip on;
gzip_types text/plain application/xml text/css application/javascript;
gzip_min_length 1000;
location / {
# Proxy to Node.JS instance
proxy_pass http://node:3000;
expires $expires;
proxy_redirect off;
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;
# Websocket support
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 all API requests
location /api {
proxy_pass http://nginx:81;
}
}
#--------------------------------------------------------
# Laravel server configuration
#--------------------------------------------------------
server {
#listen 443 ssl;
listen 81;
index index.php index.html;
root /var/www/api/public;
charset utf-8;
client_max_body_size 20m;
# SSL for 443
#ssl_certificate /etc/nginx/ssl/ssl-cert-snakeoil.pem;
#ssl_certificate_key /etc/nginx/ssl/ssl-cert-snakeoil.key;
location / {
try_files $uri $uri/ /index.php?$args;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
# Handle all php files (which will always be just /index.php)
# via factcgi PHP-FPM unix socket
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php-fpm:9000;
fastcgi_index index.php;
# For comfortable debugging
fastcgi_read_timeout 1000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
我想在
/admin
文件夹中为admin添加另一个nuxt.js应用程序。但是我现在一个星期都不能把脑袋放在它上面。所有尝试最终都会在生成时出错。我应该向docker compose.yml
和nginx
config添加什么 我不确定,但我认为您需要为您的服务设置一个“容器名称”,如下所示:
node:
container_name: node_container
build:
context: docker/node
dockerfile: Dockerfile
# ...
nginx需要签入proxy_pass
location / {
# Proxy to Node.JS instance
proxy_pass http://node_container:3000;
我希望我已经理解并帮助了您的请求我不确定,但我认为您需要为您的服务设置一个“容器名称”,如下所示:
node:
container_name: node_container
build:
context: docker/node
dockerfile: Dockerfile
# ...
nginx需要签入proxy_pass
location / {
# Proxy to Node.JS instance
proxy_pass http://node_container:3000;
我希望我已经理解并帮助您的请求现在这些文件中有什么?请在问题本身中添加这些细节,而不是在外部链接后面(并作为文本,而不是任何东西的图像或截图)。更新了我的帖子。谢谢现在那些文件里有什么?请在问题本身中添加这些细节,而不是在外部链接后面(并作为文本,而不是任何东西的图像或截图)。更新了我的帖子。感谢此解决方案为我提供了一个新错误
2020/07/10 19:29:13[emerg]1#1:host未在/etc/nginx/conf.d/app.conf:25中的上游“container_name”中找到,但我的nuxtjs应用程序通过localhost:3000(nginx外部)运行正常也许你忘了在docker-compose.yaml中公开节点服务中的端口3000?这个解决方案给我带来了一个新错误2020/07/10 19:29:13[emerg]1#1:host未在/etc/nginx/conf.d/app.conf:25中的上游“container_name”中找到,但我的nuxtjs应用程序通过localhost:3000(nginx外部)运行良好也许您忘了在docker-compose.yaml中公开节点服务中的端口3000?