Reputation: 301
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;
}
}
here I've putted all the configs I cut find, but I still getting an 504 timeout error on uploading a file about 20 megabytes, its less than 2 minutes, can you look at these settings and tell me what I'am missing?, I've restarted the server after putting all this, but didn't helped, please help! Ican't upload files
Upvotes: 0
Views: 2380
Reputation: 3442
Updated
You need to configure fastcgi_read_timeout
in your location
scopes.
location {
...
fastcgi_read_timeout 900s; # 15 minutes
...
}
Also what you can do to clean up your config (this is optional) is you can putt all the proxy_set_headers along with timeout in e.g. /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;
Then you can remove all the proxy_set_header
so you do not have to repeat them, and put this instead of them:
include /etc/nginx/fastcgi_settings
That will make your config easier to maintain.
Old Answer
These variables must be defined in server
scope, not in http
scope. Also, if you are proxying to php, you also need to set
proxy_read_timeout 120;
proxy_connect_timeout 120;
If you are still having problems, please provide full configuration.
Upvotes: 1