docker - 将docker中的nginx conf映射到正确的位置
问题描述
我一直在努力对我的 docker app 进行更改。经过大量试验和错误后,我认为我的 nginx conf 文件实际上可能不是我的 nginx conf 文件。
我已经确定了这一点,因为我尝试完全删除它并且我的应用程序与 docker 运行相同。
看起来我通过 app.conf 文件对我的 nginx 服务所做的更改对我的应用程序的其余部分没有影响。
我试图了解我的卷映射是否正确。这是我的码头工人撰写:
version: "3.5"
services:
collabora:
image: collabora/code
container_name: collabora
restart: always
cap_add:
- MKNOD
environment:
- "extra_params=--o:ssl.enable=false --o:ssl.termination=true"
- domain=mydomain\.com
- dictionaries=en_US
ports:
- "9980:9980"
volumes:
- ./appdata/collabora:/config
nginx:
image: nginx:1.15-alpine
restart: unless-stopped
depends_on:
- certbot
- collabora
volumes:
# - ./data/nginx:/etc/nginx/conf.d
- ./data/nginx:/etc/nginx
- ./data/certbot/conf:/etc/letsencrypt
- ./data/certbot/www:/var/www/certbot
ports:
- "80:80"
- "443:443"
command: "/bin/sh -c 'while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g \"daemon off;\"'"
certbot:
image: certbot/certbot
restart: unless-stopped
volumes:
- ./data/certbot/conf:/etc/letsencrypt
- ./data/certbot/www:/var/www/certbot
entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"
我的项目目录是:
/我的项目
- docker-compose.yaml
- 数据
- nginx
- 应用程序.conf
- nginx
然后我的 app.conf 有各种 nginx 设置
server {
listen 80;
server_name example.com www.example.com;
server_tokens off;
location /.well-known/acme-challenge/ {
root /var/www/certbot;
}
location / {
return 301 https://$host$request_uri;
}
} ... more settings below
假设我的 app.conf 文件没有被使用是正确的,我怎样才能正确地将本地的 app.conf 映射到 nginx 容器中的正确位置?
解决方案
nginx conf目录是
/etc/nginx/nginx.conf
此文件包含来自的所有内容
/etc/nginx/conf.d/*
您可以验证您的 nginx.conf 正在使用执行ps -ef | grep nginx在你的容器上。验证您的 default.conf。无论如何,在你的作文中你必须有:
volumes:
- ./data/nginx:/etc/nginx/conf.d
尝试使用绝对路径
问候
推荐阅读
- python - python中arma-garch模型的预测区间
- pdf - 如何将整个网站变成PDF文件?
- arrays - 具有创建新数据框功能的多维数组
- python - 如何生成形成四面体的随机顶点?
- python - 有没有比这更好的方法来获取 Unicorn 中的所有注册键(在 python 中)?
- git - 从分支拉取更改推送到服务器
- json - 如何在 Java/JSON 中处理 POST 请求中的转义字符?
- arrays - 列表如何以 Common Lisp 中的数组不可能的方式共享结构?
- c# - 无法加载文件或程序集“Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter”或其依赖项之一。系统找不到文件
- web-config - aspnet_regiis 说成功但 connectionString 部分未更改