Nginx 학습 총화 (12) - Nginx 각 설정 총화
                                            
 4618 단어  Nginx 학습 총화NginxNginx 설정
                    
user www www; //          ,        2. nginx 프로 세 스 수, CPU 총 핵심 수 설정 권장
worker_processes 8;3. 설정 파일 의 정확성 테스트
./nginx -t //                  4, 전역 오류 로그 정의 형식, [디버그 | info | notice | warn | error | crt]
error_log /var/log/nginx/error.log info;5. 프로 세 스 파일
pid /var/run/nginx.pid;6. 하나의 nginx 프로 세 스 가 열 린 가장 많은 파일 설명자 수 입 니 다. 이론 적 값 은 파일 수 (시스템 의 값 ulimit - n) 와 nginx 프로 세 스 수 를 제외 해 야 합 니 다. 그러나 nginx 배분 요청 이 고 르 지 않 기 때문에 ulimit - n 의 값 과 일치 하 는 것 을 권장 합 니 다.
worker_rlimit_nofile 65535;7. http 서버 설정
http{
include mime.types; #             
default_type application/octet-stream; #      8、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; #     
sendfile on; #          ,sendfile    nginx    sendfile       ,         on,             IO     ,    off,        I/O    ,       。  :              off。
autoindex on; #        ,       ,    。
tcp_nopush on; #      
tcp_nodelay on; #      
keepalive_timeout 120; #       ,    9. 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;10. gzip 모듈 설정
gzip on; #  gzip    
gzip_min_length 1k; #        
gzip_buffers 4 16k; #     
gzip_http_version 1.0; #    (  1.1,     squid2.5   1.0)
gzip_comp_level 2; #    
gzip_types text/plain application/x-javascript text/css application/xml;11. 압축 형식 은 기본적으로 text / html 이 포함 되 어 있 기 때문에 아래 는 더 이상 쓰 지 않 아 도 됩 니 다. 써 도 문제 가 없 지만 warn 이 있 습 니 다.
gzip_vary on;12. 부하 균형
upstream blog.ha97.com {
#upstream     ,weight   ,            。weigth      ,             。
server 192.168.80.121:80 weight=3;
server 192.168.80.122:80 weight=2;
server 192.168.80.123:80 weight=3;
}13. 가상 호스트 의 설정
server{
#    
listen 80;
#       ,     
server_name www.ha97.com ha97.com;
index index.html index.htm index.php;
root /data/www/ha97;
location ~ .*.(php|php5)?$
{
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}14. 이미지 캐 시 시간 설정
location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 10d;
}15. JS 와 CSS 캐 시 시간 설정
location ~ .*.(js|css)?$
{
expires 1h;
}16. 로그 형식 설정
log_format access '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" $http_x_forwarded_for';17. 본 가상 호스트 의 접근 로 그 를 정의 합 니 다.
access_log /var/log/nginx/ha97access.log access;18. "/" 에 대한 역방향 프 록 시 사용 하기
location / {
proxy_pass http://127.0.0.1:88;
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;19. Nginx 동정 분리 설정
#    Nginx     
location /NginxStatus {
stub_status on;
access_log on;
auth_basic "NginxStatus";
auth_basic_user_file conf/htpasswd;
#htpasswd        apache   htpasswd     。
}
#            
#  jsp      tomcat resin  
location ~ .(jsp|jspx|do)?$ {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:8080;
}
#       nginx       tomcat resin
location ~ .*.(htm|html|gif|jpg|jpeg|png|bmp|swf|ioc|rar|zip|txt|flv|mid|doc|ppt|pdf|xls|mp3|wma)
#            
root /var/lib/tomcat7/webapps/JieLiERP/WEB-INF ;
expires 15d;
location ~ .*.(js|css)
expires 1h;
 }
}이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
SSR 배포 전략 with EC2, CloudFront, pm2, NGINX (2)Ubuntu에서 기존의 http의 80번 포트로 리다이렉트할 수 있지만, 추가적으로 도메인을 등록하고 HTTPS 설정 등을 위해 NGINX를 사용해볼 것이다. 도메인을 등록하기 위해 AWS Route 53을 검색하고...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.