我正在尝试在nextcloud
泊坞窗中指向/var/www/nextcloud
的子目录中运行nginx
泊坞窗。
但无论我做什么,当我访问它时,nginx会继续尝试提供/var/www/nextcloud/nextcloud
。
这是ngix.conf
(注意root /var/www;
行)
user www-data;
http {
upstream backend {
server nextcloud:9000;
}
upstream php-handler {
server nextcloud:9000;
}
server {
listen 80;
# Add headers to serve security related headers
# Before enabling Strict-Transport-Security headers please read into this
# topic first.
#add_header Strict-Transport-Security "max-age=15768000;
# includeSubDomains; preload;";
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header X-Robots-Tag none;
add_header X-Download-Options noopen;
add_header X-Permitted-Cross-Domain-Policies none;
# Path to the root of your installation
root /var/www;
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
# The following 2 rules are only needed for the user_webfinger app.
# Uncomment it if you're planning to use this app.
# rewrite ^/.well-known/host-meta /nextcloud/public.php?service=host-meta
# last;
#rewrite ^/.well-known/host-meta.json
# /nextcloud/public.php?service=host-meta-json last;
location = /.well-known/carddav {
return 301 $scheme://$host/nextcloud/remote.php/dav;
}
location = /.well-known/caldav {
return 301 $scheme://$host/nextcloud/remote.php/dav;
}
location /.well-known/acme-challenge { }
location ^~ /nextcloud {
# set max upload size
client_max_body_size 512M;
fastcgi_buffers 64 4K;
# Enable gzip but do not remove ETag headers
gzip on;
gzip_vary on;
gzip_comp_level 4;
gzip_min_length 256;
gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy;
# Uncomment if your server is build with the ngx_pagespeed module
# This module is currently not supported.
#pagespeed off;
location /nextcloud {
rewrite ^ /nextcloud/index.php$uri;
}
然后我在我的nginx docker-compose.yml
中有以下内容(请注意卷中的- /mnt/server/nextcloud:/var/www/nextcloud
行:
web:
image: nginx
container_name: nginx-webserver
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
- /mnt/server/nextcloud:/var/www/nextcloud
external_links:
- nextcloud
environment:
- VIRTUAL_HOST=${DOMAIN}
- VIRTUAL_NETWORK=nginx-proxy
- VIRTUAL_PORT=80
- LETSENCRYPT_HOST=${DOMAIN}
- LETSENCRYPT_EMAIL=myemail
networks:
- proxy-tier
restart: always
networks:
proxy-tier:
external:
name: nginx-proxy
最后我的docker-compose.yml
为nextcloud(注意卷的- /mnt/server/nextcloud/:/var/www/html/
行):
version: '2'
services:
nextcloud:
image: nextcloud:fpm
container_name: nextcloud
links:
- db
volumes:
- /mnt/server/nextcloud/:/var/www/html/
- /mnt/server/nextcloud/apps:/var/www/html/apps/
- /mnt/server/nextcloud/config:/var/www/html/config/
- /mnt/server/nextcloud/data:/var/www/html/data/
networks:
- proxy-tier
restart: always
networks:
proxy-tier:
external:
name: nginx-proxy