Welcome! Log In Create A New Profile

Advanced

Re: Images not loading sometimes with NGINX as RP

March 13, 2012 09:04AM
As I said, I've also had this before with the default config. Anyway, here you go:


nginx.conf
-----------
user nginx;
worker_processes 6;
worker_rlimit_nofile 8000;

error_log /var/log/nginx/error.log;

pid /var/run/nginx.pid;

events {
worker_connections 4096;
use epoll;
}

http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
open_file_cache max=60000 inactive=300s;
open_file_cache_valid 360s;
open_file_cache_min_uses 2;
open_file_cache_errors off;
server_names_hash_bucket_size 64;

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;

client_body_temp_path /var/spool/nginx-client-body 1 2;
client_max_body_size 32m;
client_body_buffer_size 128k;
client_header_buffer_size 2k;
large_client_header_buffers 4 16k;

server_tokens off;

sendfile on;
tcp_nopush on;
tcp_nodelay off;

keepalive_timeout 3;
keepalive_requests 10;
client_body_timeout 5;
client_header_timeout 5;
send_timeout 5;

proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=nginxcache:10m inactive=10m max_size=1000m;
proxy_temp_path /var/cache/nginx/proxy;
proxy_cache_key "$scheme://$host$request_uri";

gzip on;
gzip_http_version 1.0;
gzip_comp_level 1;
gzip_proxied any;
gzip_min_length 10;
gzip_buffers 16 8k;
gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
gzip_disable "MSIE [1-6].(?!.*SV1)";
gzip_vary on;

proxy_redirect off;

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_max_temp_file_size 0;

proxy_connect_timeout 30;
proxy_send_timeout 90;
proxy_read_timeout 90;

proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;

include /etc/nginx/conf.d/*.conf;

}


vhost.conf
------------
upstream server {
server 1.2.3.4:80 weight=1 fail_timeout=30s;
}

server {
listen 80;
server_name .domain.com;
access_log /var/log/nginx/domain.com_access.log;
error_log /var/log/nginx/domain.com.net_error.log;

location / {
proxy_pass http://server;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_cache nginxcache;
proxy_cache_valid 200 30m;
}

location ~* \.(jpg|png|gif|jpeg|css|js|swf|doc|pdf|xls|ppt|docx|pptx|xlsx)$ {
proxy_cache_valid 200 30m;
expires 604800;
proxy_pass http://server;
proxy_cache nginxcache;
}

}
Subject Author Posted

Images not loading sometimes with NGINX as RP

Infinitnet March 13, 2012 08:46AM

Re: Images not loading sometimes with NGINX as RP

Antonio P.P. Almeida March 13, 2012 08:56AM

Re: Images not loading sometimes with NGINX as RP

Infinitnet March 13, 2012 09:04AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 330
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready