我正在尝试使用 Raspberry Pi 在本地 nextwork 上设置 Nextcloud 服务器。为此,我使用了 3 个 docker 镜像:nextcloud、posgresql 和 nginx。但即使我只想在本地网络中使用此云,我也希望将 Nextcloud 配置为通过 https 工作以更安全。到目前为止,我尝试了很多方法,但都没有奏效。这是我的 docker-compose.yml 文件和 nginx.conf 文件。
你能帮助我吗?
Docker-compose.yml 文件:
version: '3'
services:
nextcloud:
image: nextcloud
container_name: nextcloud
environment:
- POSTGRES_HOST=db
- POSTGRES_DB=nextcloud
- POSTGRES_USER=nextcloud
- POSTGRES_PASSWORD=mypassword
ports:
- 8080:80
volumes:
- /MyCloud/nextcloud:/var/www/html
- /MyCloud/data:/var/www/html/data
- /MyCloud/apps:/var/www/html/custom_apps
- /MyCloud/config:/var/www/html/config
- /MyCloud/themes:/var/www/html/themes
networks:
- nextcloud-net
depends_on:
- db
db:
image: postgres:latest
container_name: postgres
environment:
- POSTGRES_DB=nextcloud
- POSTGRES_USER=nextcloud
- POSTGRES_PASSWORD=mypassword
volumes:
- /db:/var/lib/postgresql/data
networks:
- nextcloud-net
nginx:
image: nginx
container_name: nginx
volumes:
- /certs/nextcloud.crt:/etc/nginx/certs/nginx.crt
- /certs/nextcloud.key:/etc/nginx/certs/nginx.key
- /nginx/nginx.conf:/etc/nginx/conf.d
ports:
- 443:443
networks:
- nextcloud-net
networks:
nextcloud-net:
driver: bridge
以及 nginx.conf 文件:
server {
listen 80;
server_name 10.0.0.124;
location / {
return 301 https://$host$request_uri;
}
}
server {
listen 443 ssl;
server_name 10.0.0.124;
ssl_certificate /etc/nginx/certs/nginx.crt;
ssl_certificate_key /etc/nginx/certs/nginx.key;
location / {
proxy_pass http://nextcloud;
proxy_set_header Host $host;
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;
}
}
当我尝试连接到http://10.0.124:8080,它会加载 Nextcloud 页面。但是当我尝试连接到https://10.0.0.124,什么都没加载。浏览器错误的屏幕截图: 浏览器截图
我试过
- docker-compose.yml 和 nginx.conf 文件的许多不同配置(例如端口 8080:443、80:443 等)
- 重新生成自签名证书
- 检查防火墙
我希望 Web 访问仅通过 https 进行。而不是 http。