у вас четыре огурца, которые надо сегодня съесть.
user www-data;
worker_processes 1;
pid /var/run/nginx.pid;
events {
worker_connections 4096;
multi_accept on;
}
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
client_max_body_size 100M;
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";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 5;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
map $host $host_wo_www {
default $host;
~^www\.(?P<wo_www>.+)$ $wo_www;
}
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
server {
listen 80;
server_name ~^(?:www\.)?(?P<host_wo_www>.+)$;
server_name_in_redirect off;
resolver 127.0.0.1;
access_log /var/log/httpd/$host/access.log;
location ~* \.(?:jpe?g|gif|png|ico|css|zip|tgz|gz|rar|bz2|dic|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|swf|flv|mp3)$
{
root /var/www/$host_wo_www/www;
access_log off;
expires 30d;
add_header Pragma public;
add_header Cache-Control public;
}
location / {
root /var/www/$host_wo_www/www;
index index.html index.htm index.php;
access_log off;
proxy_pass http://127.0.0.1:8081;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}