这是我的船坞-Compose.yml
...
frontend:
container_name: docker-frontend
build: ./frontend
restart: unless-stopped
command: serve -s dist/vu4y-frontend -l 4200
networks:
- docker-network
nginx:
image: nginx:stable-alpine
container_name: docker-nginx
ports:
- "80:80"
volumes:
- ./data/nginx/app.conf:/etc/nginx/conf.d/nginx.conf
depends_on:
- frontend
- backend
networks:
- docker-network
...
编制配置app.conf文件:
server {
listen 80;
server_name mysite.com;
location / {
proxy_pass http://frontend:4200;
}
}
这个很好用。但经过一些更新后,停止了工作。我把所有东西都还回去了,但还是不起作用。我总是尝试重新运行服务器并删除容器中的docker nginx映像,它不起作用。
当我在当地运行时,一切都很好。但是在prod服务器中,我看到404。也许在nginx中有缓存或者其他什么东西。
在日志文件中,我没有看到任何错误。
....
docker-nginx | /docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
docker-nginx | /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
alienmova-docker-nginx | /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
docker-nginx | 10-listen-on-ipv6-by-default.sh: info: IPv6 listen already enabled
docker-nginx | /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
docker-nginx | /docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
docker-nginx | /docker-entrypoint.sh: Configuration complete; ready for start up
docker-nginx | 2022/07/14 19:53:51 [notice] 1#1: using the "epoll" event method
docker-nginx | 2022/07/14 19:53:51 [notice] 1#1: nginx/1.22.0
docker-nginx | 2022/07/14 19:53:51 [notice] 1#1: built by gcc 11.2.1 20220219 (Alpine 11.2.1_git20220219)
docker-nginx | 2022/07/14 19:53:51 [notice] 1#1: OS: Linux 5.4.0-122-generic
docker-nginx | 2022/07/14 19:53:51 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
docker-nginx | 2022/07/14 19:53:51 [notice] 1#1: start worker processes
docker-nginx | 2022/07/14 19:53:51 [notice] 1#1: start worker process 23
docker-nginx | 2022/07/14 19:53:51 [notice] 1#1: start worker process 24
....
docker-nginx | 159.223.63.89 - - [14/Jul/2022:20:03:05 +0000] "GET /cms/wp-includes/wlwmanifest.xml HTTP/1.1" 404 1653 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36" "-"
docker-nginx | 159.223.63.89 - - [14/Jul/2022:20:03:05 +0000] "GET /sito/wp-includes/wlwmanifest.xml HTTP/1.1" 404 1653 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36" "-"
docker-nginx | 159.223.63.89 - - [14/Jul/2022:20:03:06 +0000] "" 400 0 "-" "-" "-"
任何帮助都会非常有用。
发布于 2022-11-10 08:21:39
这可能与主题无关,但如果它是生产服务器,则不应该在生产中使用ng serve
来服务您的角度应用程序,因为这将占用更多的服务器资源,因为该命令会使您的代码不断等待更改并重新构建(如果有)。
对于生产,请使用ng build --prod
,然后让nginx服务于dist文件夹
https://stackoverflow.com/questions/72986174
复制相似问题