我正在使用Vue和docker开发一个应用程序,并且正在构建一个VuePress站点作为项目文档。我的项目有两个docker-compose文件,分别用于开发和生产。目前我的Vue应用程序在开发和生产环境下都工作得很好,但我正在努力让我的VuePress与NGINX一起工作。
upstream docs {
server vuepress:8080;
}..。
location /docs/ {
proxy_pass http://docs/;
}在我的开发docker-compose文件中,我为VuePress提供了以下内容:
vuepress:
container_name: vuepress_dev_vet
build:
context: .
dockerfile: ./vuepress/dev/Dockerfile
command: npm run docs:dev
volumes:
- ./vuepress/src/:/app/
networks:
- main
ports:
- 8085:8080下面是我的VuePress文件夹的结构:
.
├── dev
│ └── Dockerfile
└── src
├── docs
│ ├── guide
│ │ └── README.md
│ ├── README.md
│ └── start
│ └── README.md
└── package.json我可以在localhost:8085上访问VuePress应用程序,当我保存源文件并刷新浏览器时,更改会反映出来。我想要做的是配置docker和NGINX,使开发中的localhost/docs和生产中的my-domain.com/docs都可以访问VuePress应用。我的配置中是否有错误?
当我访问localhost/docs时,我在Chrome中得到以下错误:
Uncaught SyntaxError: Unexpected token <发布于 2018-12-20 03:33:53
下面是适用于我使用richarvey/nginx-php-fpm:latest的配置。
mydomain.localhost.conf
server {
server_name mydomain.localhost;
charset utf-8;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://localhost:35432;
}
}/etc/主机
0.0.0.0 mydomain.localhostmydomain/.vuepress/config.js
module.exports = {
title: 'MyDomain',
host: '0.0.0.0',
port: 35432
}https://stackoverflow.com/questions/53856972
复制相似问题