user webroot; worker_processes 4; worker_cpu_affinity 1000 0100 0010 0001; worker_rlimit_nofile 65506; error_log /opt/nginx/logs/error.log; #error_log /var/log/nginx/error.log notice; #error_log /var/log/nginx/error.log info; pid /opt/nginx/logs/nginx.pid; events { worker_connections 65506; } http { include mime.types; default_type application/octet-stream; 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 /opt/nginx/logs/access.log main; sendfile on; #tcp_nopush on; server_tokens off; #keepalive_timeout 0; keepalive_timeout 65; fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; fastcgi_buffer_size 64k; fastcgi_buffers 4 64k; fastcgi_busy_buffers_size 128k; fastcgi_temp_file_write_size 128k; gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_http_version 1.0; gzip_comp_level 2; gzip_types text/plain application/x-javascript text/css application/xml; gzip_vary on; # Load config files from the /etc/nginx/conf.d directory # The default server is in conf.d/default.conf #include /etc/nginx/conf.d/*.conf; server { listen 8001; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { root /home/webroot; index index.php index.html index.htm; } location ~ .php$ { root /home/webroot; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; include fastcgi.conf; } error_page 404 /404.html; location = /404.html { root /opt/nginx/html-error; } # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /opt/nginx/html-error; } } server { listen 443; server_name www.soulct.cn; if ($scheme = http) { return 301 https://$server_name$request_uri; ##访问http跳转到https } ssl on; ssl_certificate ssl/server.crt; ssl_certificate_key ssl/server.key; ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; location / { include uwsgi_params; uwsgi_pass 127.0.0.1:9091; access_log off; } location ~ ^/static/ { #配置静态文件 root /data/django_project/blogproject; expires 24h; access_log off; } } server { listen 4433; server_name www.soulct.cn; if ($scheme = http) { return 301 https://$server_name$request_uri; ##访问http跳转到https } ssl on; ssl_certificate ssl/server.crt; ssl_certificate_key ssl/server.key; ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; location / { root /home/webroot/sylist; index index.php index.html index.htm; auth_basic "Welcom to chenjianwen webside!"; auth_basic_user_file htpasswd; ##启用用户认证 #autoindex on; } } }