4

我正在尝试nextcloud在指向 docker 的子目录中/var/www/nextcloud运行nginxdocker。

但无论我做什么,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
4

0 回答 0