Nginx无限文件上传

问题描述 投票:0回答:1

当我尝试将文件上传到我的服务器时,我得到无限上传。不过,上传文件效果很好。

我的/etc/nginx/nginx.conf:

user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
        worker_connections 768;
        # multi_accept on;
}

http {

        ##
        # Basic Settings
        ##

        sendfile on;
        tcp_nopush on;
        types_hash_max_size 2048;
        # server_tokens off;

        # server_names_hash_bucket_size 64;
        # server_name_in_redirect off;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        ##
        # SSL Settings
        ##

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
        ssl_prefer_server_ciphers on;

        ##
        # Logging Settings
        ##

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        ##
        # Virtual Host Configs
        ##

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;

        client_max_body_size 128M;
        proxy_max_temp_file_size 0;
        proxy_buffering off;
        server_names_hash_bucket_size 256;
}

我的/etc/nginx/sites-available/default:

server {
    server_name zizzu.com;
    listen 80;

    # We miss all the declarations to make tls happens
    # But they should be somewhere here

    root /home/zizzu/Zizzu-API/Public/;

    # Serve all public/static files via nginx and then fallback to Vapor for the rest
    location / {
        proxy_pass http://127.0.0.1:8080;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }

    client_max_body_size 128M;

    # Proxy configuration for binding to Vapor port
    location @proxy {
        proxy_pass http://127.0.0.1:8080;
        proxy_pass_header Server;
        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_pass_header Server;
        proxy_connect_timeout 3s;
        proxy_read_timeout 10s;
    }
}

如果我像这样更改默认文件:

...
    location / {
        proxy_pass http://127.0.0.1:8080;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        try_files $uri @proxy;
    }
...

我的网络套接字抛出 101 交换协议错误。 我需要在 nginx 默认文件和 nginx.conf 文件中更改什么?

nginx websocket file-upload nginx-config
1个回答
0
投票

我解决了我的问题。

我的新/etc/nginx/sites-available/default:

server {
    server_name zizzu.com;
    listen 80;

    # We miss all the declarations to make tls happens
    # But they should be somewhere here

    root /home/zizzu/Zizzu-API/;

    # Serve all public/static files via nginx and then fallback to Vapor for the rest
    location / {
        proxy_pass http://127.0.0.1:8080;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }

    location /photos/new {
        try_files $uri @proxy;
    }

    location /graphql {
        try_files $uri @proxy;
    }

    client_max_body_size 128M;

    # Proxy configuration for binding to Vapor port
    location @proxy {
        proxy_pass http://127.0.0.1:8080;
        proxy_pass_header Server;
        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_pass_header Server;
        proxy_connect_timeout 3s;
        proxy_read_timeout 10s;
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.