SeouliteLab

nginx 프록시(proxy), gzip, ssl, 로드벨런싱(load balancing) 설정 본문

프로그래밍

nginx 프록시(proxy), gzip, ssl, 로드벨런싱(load balancing) 설정

Seoulite Lab 2018. 4. 30. 15:09

nginx.conf 파일 수정



#user  nobody;

worker_processes  1;


#error_log  logs/error.log;

#error_log  logs/error.log  notice;

#error_log  logs/error.log  info;


#pid        logs/nginx.pid;



events {

    worker_connections  1024;

}



http {

    include       mime.types;

    default_type  application/octet-stream;


    #access_log  logs/access.log  main;


    sendfile        on;


    keepalive_timeout  65;


   #gzip 설정

    gzip on;

    gzip_disable "msie6";


    gzip_vary on;

gzip_min_length  1100;

    gzip_proxied any;

    gzip_comp_level 6;

    gzip_buffers 4 32k;

    gzip_http_version 1.1;

    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;

 



  #로드 벨런싱 설정

upstream test_was {

server localhost:8080;

server localhost:8081;

}

 

    server {

        listen       81;

        server_name  test.co.kr;


        #charset koi8-r;


        #access_log  logs/host.access.log  main;

location / {

#proxy_pass http://localhost:8080;

proxy_pass http://test_was;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_set_header Host $http_host;

        }

  #81번 포트로 들어오는건 https 로 이동

return 301 https://$host$request_uri;


    }

    server {

        listen       443 ssl;

        server_name  test.co.kr;

  #ssl 설정

ssl                  on;

ssl_certificate      D:/testssl/test.co.kr.crt;

ssl_certificate_key  D:/testssl/test.co.kr.key;

ssl_session_timeout  5m;

ssl_protocols  SSLv2 SSLv3 TLSv1;

ssl_ciphers  HIGH:!aNULL:!MD5;

ssl_prefer_server_ciphers   on;

location ~ /\.ht {

deny  all;

}

location / {

#proxy_pass http://localhost:8080;

proxy_pass http://test_was;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_set_header Host $http_host;

        }


    }


}