问题描述
做Excel导入的功能,由于Excel的数据比较多,需要做处理然后入库,数据量大概200万,所以毫无悬念的导入Excel接口调用超过了一分钟,并且报错:504 gateway timeout。
解决方案
nginx超时限制。路径/etc/nginx/nginx.conf
,查看配置
user root;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
client_max_body_size 10M;
client_body_buffer_size 12M;
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;
gzip on;
gzip_buffers 32 4K;
gzip_comp_level 6;
gzip_min_length 100;
gzip_types application/javascript text/css text/xml;
gzip_disable "MSIE [1-6]\."; #配置禁用gzip条件,支持正则。此处表示ie6及以下不启用gzip(因为ie低版本不支持)
gzip_vary on;
include /etc/nginx/myconfig/*.conf;
include /etc/nginx/conf.d/*.conf;
}
include /etc/nginx/myconfig/*.conf
为自定义配置
如果使用了Nginx的代理,可以在块里加上:
proxy_connect_timeout 300s;
proxy_send_timeout 300s;
proxy_read_timeout 300s;
这里修改为:
server {
listen 18866;
server_name 192.168.0.2;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
root /var/www/zjy/sbasestation/dist;
index index.html index.htm;
}
location /algo {
proxy_pass http://localhost:18818;
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;
proxy_connect_timeout 3600s;
proxy_send_timeout 3600s;
proxy_read_timeout 3600s;
}
}