nginx 后面的 Docker Nextcloud 和 proxy_pass 不起作用

nginx 后面的 Docker Nextcloud 和 proxy_pass 不起作用

我尝试通过 nginx 和子域传递 nextcloud docker 和 apache。但我仍然从主站点收到 index.html。

    server {
            listen 80 default_server;
            listen [::]:80 default_server;
    
            root /var/www/html;
    
            # Add index.php to the list if you are using PHP
            index index.html index.htm index.nginx-debian.html index.php;
    
            server_name _;
            location /.well-known/acme-challenge/ {
                root /var/www/certbot;
            }
    
            location / {
                    try_files $uri $uri/ =404;
            }
    
            location ~ /\.ht {
                   deny all;
            }
    }
    
    server {
        listen 443 ssl http2;
        listen [::]:443 ssl http2;
    
        server_name nextcloud.domain.tl;
    
        client_max_body_size 0;
        underscores_in_headers on;
        
        location ~ {
                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;
                add_header Front-End-Https on;
    
                proxy_headers_hash_max_size 512;
                proxy_headers_hash_bucket_size 64;
    
                proxy_buffering off;
                proxy_redirect off;
                proxy_max_temp_file_size 0;
                proxy_pass http://192.168.1.100:8080;
            }
    
            ssl_certificate /etc/letsencrypt/live/domain.tl-0001/fullchain.pem;
            ssl_certificate_key /etc/letsencrypt/live/domain.tl-0001/privkey.pem;
            include /etc/letsencrypt/options-ssl-nginx.conf;
            ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
        
    }
    
    server {
            listen 443 ssl;
            server_name domain.tl;
    
            ssl_certificate /etc/letsencrypt/live/domain.tl-0001/fullchain.pem;
            ssl_certificate_key /etc/letsencrypt/live/domain.tl-0001/privkey.pem;
            include /etc/letsencrypt/options-ssl-nginx.conf;
            ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
    
            root /var/www/html;
    
            location ~ /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;
                proxy_set_header X-Forwarded-Host $server_name;
                client_max_body_size 1G;
                proxy_pass http://192.168.1.100:8080;
        }
    }

对于 proxy_pass,我在环境中添加了 truste_proxies 并覆盖

  app:
    image: nextcloud
    restart: always
    ports:
      - 8080:80
    links:
      - db
    volumes:
      - /home/user/docker/nextcloud/nextcloud/data:/var/www/html
    environment:
      - MYSQL_PASSWORD=pass1
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
      - MYSQL_HOST=db
      - PHP_UPLOAD_LIMIT=2048
      - APACHE_DISABLE_REWRITE_IP=1
      - TRUSTED_PROXIES=192.168.0.0/16
      - OVERWRITECLIURL=https://nextcloud.domain.tl

当我去https://nextcloud.domain.tl我从 domain.tl 获得了 index.html

答案1

你不需要在 docker-compose 中公开端口 443 吗?

  app:
    image: nextcloud
    restart: always
    ports:
      - 8080:80
      - 443:443        # or whichever external port you want...
    links:
      - db
    volumes:
      - /home/user/docker/nextcloud/nextcloud/data:/var/www/html
    environment:
      - MYSQL_PASSWORD=pass1
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
      - MYSQL_HOST=db
      - PHP_UPLOAD_LIMIT=2048
      - APACHE_DISABLE_REWRITE_IP=1
      - TRUSTED_PROXIES=192.168.0.0/16
      - OVERWRITECLIURL=https://nextcloud.domain.tl

相关内容