Nginx 학습 총화 (14) - Nginx 설정 매개 변수 에 대한 상세 한 설명 과 정리
# Nginx
user www www;
#
#nginx , CPU .
worker_processes 8;
#
# ,[ debug | info | notice | warn | error | crit ]
error_log /var/log/nginx/error.log info;
#
#
pid /var/run/nginx.pid;
#
# nginx , ( ulimit -n) nginx , nginx , ulimit -n .
worker_rlimit_nofile 65535;
#
#
events
{
# ,use [ kqueue | rtsig | epoll | /dev/poll | select | poll ]; epoll Linux 2.6 I/O , FreeBSD , kqueue .
use epoll;
# ( = * )
worker_connections 65535;
}
#
# http
http
{
include mime.types; #
default_type application/octet-stream; #
#charset utf-8; #
server_names_hash_bucket_size 128; # hash
client_header_buffer_size 32k; #
large_client_header_buffers 4 64k; #
client_max_body_size 8m; #
# , , .
autoindex on; #
autoindex_exact_size on; # on, , bytes off , , kB MB GB
autoindex_localtime on; # off, GMT on ,
sendfile on; # ,sendfile nginx sendfile , on, IO , off, I/O , . : off.
tcp_nopush on; #
tcp_nodelay on; #
keepalive_timeout 120; # ( s) ,
# FastCGI : , . .
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
gzip on; # gzip
gzip_min_length 1k; # , header content-length . 0, . 1k , 1k
gzip_buffers 4 16k; # 4 16k , gzip
gzip_http_version 1.1; # ( 1.1, gzip . squid2.5 1.0)
gzip_comp_level 2; # .1 , .9 , cpu , , , ,
gzip_types text/plain application/x-javascript text/css application/xml;
# , text/html, , , warn.
gzip_vary on;# gzip . : squid nginx
# IP
#limit_zone crawler $binary_remote_addr 10m;
##upstream , ( )##
#
server
{
#
listen 80;
# ,
server_name ably.com;
# HTTP HTTPS
rewrite ^(.*) https://$server_name$1 permanent;
}
server
{
# HTTPS
listen 443 ssl;
server_name ably.com;
#
ssl_certificate C:\WebServer\Certs\certificate.crt;
ssl_certificate_key C:\WebServer\Certs\private.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
ssl_prefer_server_ciphers on;
index index.html index.htm index.php;
root /data/www/;
location ~ .*\.(php|php5)?$
{
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
# ,
location /oauth/{
proxy_pass https://localhost:13580/oauth/;
proxy_set_header HOST $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
#
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
expires 10d;
}
# JS CSS
location ~ .*\.(js|css)?$ {
expires 1h;
}
#
log_format access '$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 access;
# Nginx .StubStatus Nginx , , Nginx
location /NginxStatus {
stub_status on;
access_log on;
auth_basic "NginxStatus";
auth_basic_user_file conf/htpasswd;
#htpasswd apache htpasswd .
}
}
}
Nginx 부하 균형
events
{
use epoll;
worker_connections 65535;
}
http
{
##upstream , ##
# 1: . , , ,
upstream webhost {
server 192.168.0.5:6666 ;
server 192.168.0.7:6666 ;
}
# 2:weight( ). .
upstream webhost {
server 192.168.0.5:6666 weight=2;
server 192.168.0.7:6666 weight=3;
}
# 3:ip_hash. IP hash , IP , session
upstream webhost {
ip_hash;
server 192.168.0.5:6666 ;
server 192.168.0.7:6666 ;
}
# 4:url_hash( ). url hash , url , .Nginx url_hash , , Nginx hash
upstream webhost {
server 192.168.0.5:6666 ;
server 192.168.0.7:6666 ;
hash $request_uri;
}
# 5:fair( ). . , , .Nginx fair , , Nginx upstream_fair
#
# ( 3:ip_hash)
server
{
listen 80;
server_name mongo.demo.com;
# "/"
location / {
proxy_pass http://webhost;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
# Web X-Forwarded-For IP
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# , .
proxy_set_header Host $host;
client_max_body_size 10m; #
client_body_buffer_size 128k; # ,
proxy_connect_timeout 90; #nginx ( )
proxy_send_timeout 90; # ( )
proxy_read_timeout 90; # , ( )
proxy_buffer_size 4k; # (nginx)
proxy_buffers 4 32k; #proxy_buffers , 32k
proxy_busy_buffers_size 64k; # (proxy_buffers*2)
proxy_temp_file_write_size 64k;
# , , upstream
}
}
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
linux2에 nginx 설치설치 가능한 nginx를 확인하고, 해당 nginx를 설치한다. localhost 혹은 해당 ip로 접속을 하면 nginx 화면을 볼 수 있다....
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.