# Nginx serving static files very slow



## r1c0 (Mar 14, 2014)

Hey,
I have some problems with nginx. I installed nginx from ports in a ezjail . 
Nginx serving static files very slow, around 6 - 100 KB/s. Loading a website takes up to 3 minutes 

nginx.conf: 

```
user  www www;
worker_processes  4;
    
error_log  /var/log/nginx/error.log debug;
pid        /var/run/nginx.pid;
    
events {
    worker_connections  768;
}

    
http {
    include       mime.types;
    default_type  application/octet-stream;

    fastcgi_buffers 8 16k;
    fastcgi_buffer_size 32k;

         
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
 

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;

    server {
        listen       80;
        server_name  _;


        access_log  /var/log/nginx/main.access.log  main;

        location / {
            root   /usr/local/www/nginx;
            index  index.html index.htm;
  	}
    }

    include /usr/local/etc/nginx/vhosts/*;
}
```

vhost: 

```
server {

        server_name example.com;

        root /usr/local/www/example.com;

        location / {
            index index.php;
        }
        location ~ \.php$ {
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME /usr/local/www/example.com/$fastcgi_script_name;
            include fastcgi_params;
        }
}
```


Do you have any ideas how to fix this? I'm a noob in freebsd..


----------



## drhowarddrfine (Mar 14, 2014)

If you're using PHP then you're not serving static files but I assume the PHP stuff is being handled by another server which you are apparently doing on the local host. But I don't see where static files are being handled in your config cause you put everything through PHP.


----------



## r1c0 (Mar 14, 2014)

Upps bad example  

I have different vhosts with and without php, but makes no different, in all vhosts files (images, zips, ...) are downloaded at only at few KB/s 
another vhost without php:

```
server {
     
        server_name example2.com;
	access_log /var/log/nginx/access_example2.com.log combined;
	
	root /usr/local/www/example2.com/;

	autoindex on;

}
```


----------



## drhowarddrfine (Mar 14, 2014)

Remove the closing '/' from your root declaration. 

I'm new to nginx myself but am running it locally and in the process of transferring one site to a VPS running FreeBSD10 and nginx. Runs faster than the shared host it was on but I haven't set up the download links yet so I can't test those, however the images and pages themselves run fine.


----------



## r1c0 (Mar 15, 2014)

Okay nginx wasn't the problem  

add -tso to network interface solves the problem 



> The 9.0 branch seems to be particularly sensitive to odd configurations where TCP Segmentation Offload is involved. This can be "corrected" by disabling TSO:


http://serverfault.com/questions/514046 ... emely-down


----------

