JSF 和 Nginx:当服务器位于 Nginx 后面时上传文件失败

JSF and Nginx: uploading files fails when server behind Nginx

使用 JSF 2.3、Jakarta EE 8 和 Wildfly 23 / Payara 5

使用 <h:input><p:fileUpload> 上传文件工作正常 但是当 Nginx 打开时失败 。支持 bean 永远不会接收到该文件。

  1. 是否有任何配置要添加到服务器? (Payara 或 Wildfly)
  2. Nginx配置文件肯定有错误吧?

app.conf:

upstream payara{
    least_conn;

    server localhost:8080 max_fails=3 fail_timeout=5s;
    server localhost:8181 max_fails=3 fail_timeout=5s;
}
server {
    if ($host = nocodefunctions.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    listen        80;
    access_log /var/log/nginx/payara-access.log;
    error_log /var/log/nginx/payara-error.log;
    #Replace with your domain
    server_name   nocodefunctions.com;
    return        301 https://$host$request_uri;


}

server {
    listen        443 ssl;
    server_name   nocodefunctions.com;
    ssl_certificate /etc/letsencrypt/live/xxxxx/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/xxxxx/privkey.pem; # managed by Certbot

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
    ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";

    location /nocodeapp-web-front-1.0 {
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host $http_host;
            proxy_set_header X-Forwarded-Proto https;
           
            proxy_connect_timeout      240;
            proxy_send_timeout         240;
            proxy_read_timeout         240;  
            proxy_http_version 1.1;

            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_pass http://payara$request_uri;
    }
    
    location = / {
            proxy_pass http://payara;
            return 301 https://nocodefunctions.com/nocodeapp-web-front-1.0;
    }

}

问题是:我的文件大于 nginx 上传的大小限制,默认设置为 1m。

解决方案包括将 client_max_body_size 8M;(或任何其他值)添加到配置文件中,更多详细信息请参阅此 SO post