Nginx 1.27.0子域名文档根目录错误+Docker化Nextcloud虚拟主机配置出现Apache错误提示求助
Hey buddy, let's break this down step by step! That Apache error message isn't coming from your host server—it's definitely from inside your Nextcloud Docker container. Most official Nextcloud Docker images use Apache as the web server by default, so even though you're running Nginx as a reverse proxy on your host, the container itself is running Apache under the hood.
Why you're seeing that error
The "plain HTTP to SSL-enabled port" message means your Nginx reverse proxy is sending an unencrypted HTTP request to a port in the Nextcloud container that's configured for HTTPS. Alternatively, if you tried accessing the container's mapped port directly (like http://localhost:8080), the Apache inside the container is set to enforce HTTPS, hence the error.
How to fix your Nginx vhost config
Assuming you're handling SSL termination at the Nginx level (the standard recommended setup), here's how to complete your vhost configuration:
First, fill out the HTTPS server block with proper reverse proxy settings pointing to your Nextcloud container's HTTP port (usually port 80 inside the container):
server { listen 80; listen [::]:80; server_name cloud.rheno-palatia.eu; return 301 https://$host$request_uri; } server { listen 443 ssl; listen [::]:443 ssl; server_name cloud.rheno-palatia.eu; # Replace with your actual SSL certificate paths ssl_certificate /path/to/your/fullchain.pem; ssl_certificate_key /path/to/your/privkey.pem; # Reverse proxy to your Nextcloud container location / { # Use your container's name or internal IP + port 80 proxy_pass http://nextcloud-container:80; # Critical headers for Nextcloud to recognize the reverse proxy 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; } }
If you're running the Nextcloud container with HTTPS enabled internally (not recommended if you have Nginx handling SSL), you'll need to adjust the proxy_pass to use https:// and disable certificate verification if using a self-signed cert:
location / { proxy_pass https://nextcloud-container:443; 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; # Only add this if using a self-signed cert in the container proxy_ssl_verify off; }
Quick check to confirm
You can verify the Nextcloud container's web server by running:
docker exec -it your-nextcloud-container-name apache2 -v
This will show you the Apache version running inside the container, confirming that's where the error message originates.
Once you update your Nginx config, reload it with nginx -s reload and test accessing your Nextcloud subdomain again—this should resolve the "plain HTTP to SSL-enabled port" error.
备注:内容来源于stack exchange,提问作者derelektrischemoench

