user nginx;
worker_processes auto;

error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;

events {
    worker_connections 1024;
}

http {
	port_in_redirect off;
	absolute_redirect off;
    include /etc/nginx/mime.types;
    default_type application/octet-stream;
    proxy_pass_request_headers on;

    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;
    disable_symlinks off;
    server_tokens off;

    sendfile on;
    #tcp_nopush     on;

    keepalive_timeout 65;

    gzip on;

    client_max_body_size 500m;
    client_body_buffer_size 500m;

    server {
        listen 80;
        index index.php index.html index.htm default.php default.htm default.html;
        root /var/www/public;
        proxy_ignore_client_abort on;

		location / {
			try_files $uri $uri/ /index.php$is_args$query_string;
		}
		location /admin {
			try_files $uri $uri/ /admin/index.php$is_args$query_string;
		}
		location ~ [^/]\.php(/|$) {
			fastcgi_split_path_info ^(.+\.php)(.*)$;
			fastcgi_param PATH_INFO $fastcgi_path_info;
			fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
			fastcgi_pass php-fpm:9000;
			fastcgi_index index.php;
			fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
			include fastcgi_params;
			fastcgi_param SERVER_NAME $host;
		}

        #禁止访问的文件或目录
        location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md) {
            return 404;
        }

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|ico|svg)$ {
            expires 30d;
            error_log off;
            access_log off;
        }

        location ~ .*\.(js|css|json)$ {
            expires 30d;
            error_log off;
            access_log off;
        }
    }
}
