php - lxc 与 nextcloud 和 nginx 代理:未知:POST Content-Length
问题描述
我有两个 lxc 容器。一个是带有 nginx 的代理和这个配置:
server {
server_name cloud.malte-kiefer.de;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://cloud.lxd;
}
real_ip_header proxy_protocol;
set_real_ip_from 127.0.0.1;
listen [::]:443 ssl http2 proxy_protocol;
listen 443 ssl http2 proxy_protocol;
ssl_certificate /etc/nginx/ssl/cloud.malte-kiefer.de/fullchain.cer;
ssl_certificate_key /etc/nginx/ssl/cloud.malte-kiefer.de/privkey.key;
}
server {
listen 80 proxy_protocol;
listen [::]:80 proxy_protocol;
server_name cloud.malte-kiefer.de;
location / {
return 301 https://cloud.malte-kiefer.de$request_uri;
}
return 404;
}
然后我有了带有 nextcloud 的云容器,配置如下:
upstream php-handler {
server unix:/var/run/php/php7.3-fpm.sock;
}
server {
listen 80 default_server;
listen [::]:80 default_server;
set $base /var/www/html;
root /var/www/html;
index index.php index.html index.htm index.nginx-debian.html;
server_name cloud.malte-kiefer.de;
fastcgi_hide_header X-Powered-By;
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;
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
rewrite ^ /index.php;
}
location ~ ^\/(?:build|tests|config|lib|3rdparty|templates|data)\/ {
deny all;
}
location ~ ^\/(?:\.|autotest|occ|issue|indie|db_|console) {
deny all;
}
location ~ ^\/(?:index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|oc[ms]-provider\/.+)\.php(?:$|\/) {
fastcgi_split_path_info ^(.+?\.php)(\/.*|)$;
set $path_info $fastcgi_path_info;
try_files $fastcgi_script_name =404;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $path_info;
fastcgi_param HTTPS on;
fastcgi_param modHeadersAvailable true;
fastcgi_param front_controller_active true;
fastcgi_pass php-handler;
fastcgi_intercept_errors on;
fastcgi_request_buffering off;
}
location ~ ^\/(?:updater|oc[ms]-provider)(?:$|\/) {
try_files $uri/ =404;
index index.php;
}
location = /.well-known/carddav {
return 301 https://cloud.malte-kiefer.de/remote.php/dav;
}
location = /.well-known/caldav {
return 301 https://cloud.malte-kiefer.de/remote.php/dav;
}
location ~ \.(?:css|js|woff2?|svg|gif|map)$ {
try_files $uri /index.php$request_uri;
add_header Cache-Control "public, max-age=15778463";
add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;" always;
# Optional: Don't log access to assets
access_log off;
}
location ~ \.(?:png|html|ttf|ico|jpg|jpeg|bcmap)$ {
try_files $uri /index.php$request_uri;
# Optional: Don't log access to other assets
access_log off;
}
}
当我尝试打开 URL 时,我会看到来自 nextcloud 的安装页面。当我输入信息并将其从页面重新加载并在 nextcloud 日志中发送时:
未知:213 字节的 POST 内容长度超过了 Unknown#0 处 16 字节的限制
这是来自 nextcloud 容器的 nginx 日志
2020/01/13 17:32:20 [error] 416#416: *8 FastCGI sent in stderr: "PHP message: PHP Warning: Unknown: POST Content-Length of 213 bytes 超出了 Unknown on line 中 16 字节的限制0" 从上游读取响应标头,客户端:89.204.135.199,服务器:cloud.malte-kiefer.de,请求:"POST /index.php HTTP/1.0",上游:"fastcgi://unix:/var/运行/php/php7.3-fpm.sock:",主机:"cloud.malte-kiefer.de"
我检查我的 PHP ini 文件:
root@cloud:~# grep -R "post_max_size" /etc/php/
/etc/php/7.3/fpm/php.ini:post_max_size = 16GB
/etc/php/7.3/cli/php.ini:post_max_size = 16GB
/etc/php/7.3/phpdbg/php.ini:post_max_size = 8M
root@cloud:~# grep -R "memory_limit" /etc/php/
/etc/php/7.3/fpm/pool.d/www.conf:;php_admin_value[memory_limit] = 32M
/etc/php/7.3/fpm/php.ini:memory_limit = 512M
/etc/php/7.3/cli/php.ini:memory_limit = 512M
/etc/php/7.3/phpdbg/php.ini:memory_limit = 128M
我找不到问题。也许你们可以帮助我。
解决方案
好的,这是 php.ini 文件中的错误配置。我完全删除了 nextcloud 容器中的 PHP,重新安装它现在可以工作了。
推荐阅读
- django - 创建新对象而不是更新 - Django
- typescript - TypeScript 中的返回类型可以有条件地为空吗?
- python - 使用与实例无关的单独返回变量
- javascript - 动态生成的 JavaScript 方法 (JetBrains) 的自动完成建议?
- python - Keras model.fit ValueError: 形状 (None, 43) 和 (None, 1, 1, 43) 不兼容
- algorithm - 如何设置最大流量图?
- c# - CsvHelper 类型转换,带字符串和整数的列到整数
- javascript - 用 JavaScript 彻底解决汽车加油问题
- php - 如何在 Mac OS 11 上使用 Homebrew 从源代码构建后卸载 PHP 7.3
- python - 覆盖率报告显示为零