Nginx服务器搭建步骤

时间:2024-01-25 20:09:27

user nginx;

worker_processes 4;

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

pid /var/run/nginx.pid;

worker_rlimit_nofile 51200;

events {

use epoll;

worker_connections 51200;

multi_accept on;

}

http {

include /etc/nginx/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"';

log_format access '$remote_addr [$time_local] "$server_name $request" ' '$connection_requests $request_length $bytes_sent $status "$http_referer" '

'"$http_user_agent" "$http_x_forwarded_for" "$upstream_addr $upstream_status $upstream_response_time" $request_time' ;

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

server_names_hash_bucket_size 128;

client_header_buffer_size 32k;

large_client_header_buffers 4 32k;

client_max_body_size 50m;

client_body_buffer_size 128k;

sendfile on;

tcp_nopush on;

keepalive_timeout 45;

server_tokens off;

tcp_nodelay on;

proxy_set_header Host $host;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header REMOTE-HOST $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

#gzip on;

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

}