user www-data;
events {
worker_connections 768;
}
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 500;
types_hash_max_size 2048;
server_names_hash_bucket_size 64;
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
gzip on;
gzip_disable "msie6";
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
include /usr/local/ispmgr/etc/nginx.domain;
log_format isp '$bytes_sent $request_length';
server {
client_header_timeout 10m;
client_body_timeout 10m;
send_timeout 10m;
fastcgi_read_timeout 10m;
fastcgi_send_timeout 900;
proxy_read_timeout 500;
proxy_connect_timeout 500;
client_max_body_size 500m;
server_name mysite.com www.mysite.com;
listen MY_IP_ADRESS;
disable_symlinks if_not_owner from=$root_path;
set $root_path /var/www/mysite/data/www/mysite.com;
location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
root $root_path;
access_log /var/www/nginx-logs/mysite isp;
access_log /var/www/httpd-logs/mysite.com.access.log ;
error_page 404 = @fallback;
}
location / {
proxy_pass http://MY_IP_ADRESS:81;
proxy_redirect http://MY_IP_ADRESS:81/ /;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
}
location ~* ^/(webstat|awstats|webmail|myadmin|pgadmin)/ {
proxy_pass http://MY_IP_ADRESS:81;
proxy_redirect http://MY_IP_ADRESS:81/ /;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
}
location @fallback {
proxy_pass http://MY_IP_ADRESS:81;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
}
location ^~ /webstat/ {
auth_basic "Restricted area";
auth_basic_user_file /var/www/mysite/data/etc/68420649.passwd;
try_files $uri @fallback;
}
include /usr/local/ispmgr/etc/nginx.inc;
}
server {
server_name shop.mysite.com www.shop.mysite.com;
listen MY_IP_ADRESS;
charset UTF-8;
disable_symlinks if_not_owner from=$root_path;
set $root_path /var/www/mysite/data/www/shop.mysite.com;
location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
root $root_path;
access_log /var/www/nginx-logs/mysite isp;
access_log /var/www/httpd-logs/shop.mysite.com.access.log ;
error_page 404 = @fallback;
}
location / {
proxy_pass http://MY_IP_ADRESS:81;
proxy_redirect http://MY_IP_ADRESS:81/ /;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
}
location ~* ^/(webstat|awstats|webmail|myadmin|pgadmin)/ {
proxy_pass http://MY_IP_ADRESS:81;
proxy_redirect http://MY_IP_ADRESS:81/ /;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
}
location @fallback {
proxy_pass http://MY_IP_ADRESS:81;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
}
location ^~ /webstat/ {
auth_basic "Restricted area";
auth_basic_user_file /var/www/mysite/data/etc/68813297.passwd;
try_files $uri @fallback;
}
include /usr/local/ispmgr/etc/nginx.inc;
}
server {
server_name loto.mysite.com www.loto.mysite.com;
listen MY_IP_ADRESS;
charset UTF-8;
disable_symlinks if_not_owner from=$root_path;
set $root_path /var/www/mysite/data/www/loto.mysite.com;
location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
root $root_path;
access_log /var/www/nginx-logs/mysite isp;
access_log /var/www/httpd-logs/loto.mysite.com.access.log ;
error_page 404 = @fallback;
}
location / {
proxy_pass http://MY_IP_ADRESS:81;
proxy_redirect http://MY_IP_ADRESS:81/ /;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
}
location ~* ^/(webstat|awstats|webmail|myadmin|pgadmin)/ {
proxy_pass http://MY_IP_ADRESS:81;
proxy_redirect http://MY_IP_ADRESS:81/ /;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
}
location @fallback {
proxy_pass http://MY_IP_ADRESS:81;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
}
location ^~ /webstat/ {
auth_basic "Restricted area";
auth_basic_user_file /var/www/mysite/data/etc/68813303.passwd;
try_files $uri @fallback;
}
include /usr/local/ispmgr/etc/nginx.inc;
}
}
这里我已经推出了所有我发现的配置,但是我上传一个大约20兆字节的文件仍然有504超时错误,不到2分钟,你能看看这些设置并告诉我是什么丢失?,我把所有这些都重新启动了服务器,但没有帮助,请帮忙!我无法上传文件
答案 0 :(得分:0)
<强>更新强>
您需要在fastcgi_read_timeout
范围内配置location
。
location {
...
fastcgi_read_timeout 900s; # 15 minutes
...
}
你可以做些什么来清理你的配置(这是可选的)你可以把所有的proxy_set_headers和超时一起推到例如/etc/nginx/fastcgi_settings
:
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
fastcgi_read_timeout 900s;
然后你可以删除所有proxy_set_header
,这样你就不必重复它们了,而不是把它们放在一起:
include /etc/nginx/fastcgi_settings
这将使您的配置更易于维护。
旧答案
这些变量必须在server
范围内定义,而不是在http
范围内定义。另外,如果您要代理php,还需要设置
proxy_read_timeout 120;
proxy_connect_timeout 120;
如果您仍然遇到问题,请提供完整配置。