設(shè)置Nginx允許上傳文件的大小的代碼詳解
1、Nginx官方文檔說(shuō)明:
Syntax: client_max_body_size size; Default: client_max_body_size 1m; Context: http, server, location Sets the maximum allowed size of the client request body, specified in the “Content-Length” request header field. If the size in a request exceeds the configured value, the 413 (Request Entity Too Large) error is returned to the client. Please be aware that browsers cannot correctly display this error. Setting size to 0 disables checking of client request body size.
client_max_body_size 用來(lái)修改允許客戶(hù)端上傳文件的大小。默認(rèn)為1m,如果設(shè)置為0,表示上傳文件大小不受限制。
可以在以下模塊設(shè)置: http, server, location
client_max_body_size 10m;
2、設(shè)置參數(shù)
1)、在 server 模塊中設(shè)置
server { listen 80; server_name localhost; #charset koi8-r; # client_max_body_size 用來(lái)修改允許客戶(hù)端上傳文件的大小。默認(rèn)為1m,如果設(shè)置為0,表示上傳文件大小不受限制。 # 可以在以下模塊設(shè)置: http, server, location client_max_body_size 10m; # 訪問(wèn) / 網(wǎng)站跟目錄返回的內(nèi)容 location / { root /usr/share/nginx/html; index index.html index.htm; } ... }
2)、在 http 模塊中設(shè)置
http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 65; # 是否開(kāi)啟壓縮功能 #gzip on; # client_max_body_size 用來(lái)修改允許客戶(hù)端上傳文件的大小。默認(rèn)為1m,如果設(shè)置為0,表示上傳文件大小不受限制。 # 可以在以下模塊設(shè)置: http, server, location client_max_body_size 10m; # 引用配置文件 include /etc/nginx/conf.d/*.conf; }
以上就是設(shè)置Nginx允許上傳文件的大小的方法詳解的詳細(xì)內(nèi)容,更多關(guān)于設(shè)置Nginx上傳文件的大小的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!
相關(guān)文章
Nginx通過(guò)nginx-rtmp-module模塊搭建流媒體服務(wù)器實(shí)現(xiàn)直播
近日有客戶(hù)咨詢(xún)想用Nginx搭建流媒體服務(wù)器實(shí)現(xiàn)直播,方便他們打造自己的平臺(tái),經(jīng)過(guò)各種測(cè)試發(fā)現(xiàn)如下文章不錯(cuò),特分享給需要的朋友2023-10-10SpringBoot前端后端分離之Nginx服務(wù)器下載安裝過(guò)程
Nginx是一款輕量級(jí)的Web服務(wù)器/反向代理服務(wù)器及電子郵件(IMAP/POP3)代理服務(wù)器,這篇文章主要介紹了SpringBoot前端后端分離之Nginx服務(wù)器,需要的朋友可以參考下2022-08-08使用Docker實(shí)現(xiàn)Nginx反向代理
本文主要介紹了使用Docker實(shí)現(xiàn)Nginx反向代理,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2023-06-06Nginx服務(wù)器中強(qiáng)制使用緩存的配置及緩存優(yōu)先級(jí)的講解
這篇文章主要介紹了Nginx服務(wù)器中強(qiáng)制使用緩存的配置及緩存優(yōu)先級(jí)的講解,一定程度上可以幫助大家解決Nginx不緩存或緩存失效的問(wèn)題,需要的朋友可以參考下2016-01-01