- CentOS NGINX LoadBalancer
- Using Nginx as a Load Balancer
- Configuring HTTPS servers
- NGINX SSL certificate chains
- cosbynator/nginx.conf
버전 확인
cat /etc/*release*
OS bit 확인
getconf LONG_BIT
yum 속도 확장
# 설치 여부 확인 yum list installed | grep fastestmirror #설치 yum install yum-plugin-fastestmirror yum-fastestmirror
yum repository 설정
vi /etc/yum.repos.d/nginx.repo
[nginx] name=nginx repo baseurl=http://nginx.org/packages/centos/6/$basearch/ gpgcheck=0 enabled=1
Nginx 설치
yum install nginx # 시작 service nginx start
NGINX LoadBalancer
loadbalancer.conf
upstream chat_proxy { server 192.168.123.2:8080; // nodejs 1 server 192.168.123.3:8181; // nodejs 2 keepalive 64; }; server { listen 8080; listen [::]:8080 ipv6only=on; server_name doamain.com; #set $upstream_type chat_proxy; access_log /var/log/nginx/com.domain.chat-access.log; error_log /var/log/nginx/com.domain.chat-error.log error; location / { 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; proxy_set_header X-NginX-Proxy true; proxy_pass http://chat_proxy; proxy_redirect off; # Handle Web Socket connections proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } } server { listen 8080; listen [::]:8080 ipv6only=on; server_name doamain.com; #set $upstream_type chat_proxy; # You'll need to have your own certificate and key files # This is not something to blindly copy and paste ssl on; ssl_certificate /etc/ssl/com.domain/domain.crt; ssl_certificate_key /etc/ssl/com.domain/domain.key; access_log /var/log/nginx/com.domain.chat-access.log; error_log /var/log/nginx/com.domain.chat-error.log error; location / { 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; proxy_set_header X-NginX-Proxy true; proxy_pass http://chat_proxy; proxy_redirect off; # Handle Web Socket connections proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } }
nomal.conf
server { client_max_body_size 4G; client_body_buffer_size 1024k; listen *; root /home/username/www; index index.html index.htm; server_name domain.com; access_log /var/log/nginx/com.domain.chat-access.log; location / { 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; proxy_set_header X-NginX-Proxy true; proxy_pass http://127.0.0.1:3000/; proxy_redirect off; } location = /favicon.ico { log_not_found off; access_log off; } location = /robots.txt { log_not_found off; access_log off; } location = /\. { log_not_found off; access_log off; } }
Reverse Proxy
server { listen 80; location / { proxy_pass http://127.0.0.1:2812; } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } location = /favicon.ico { log_not_found off; access_log off; } location = /robots.txt { log_not_found off; access_log off; } location = /\. { log_not_found off; access_log off; } }
반응형
'lang > node' 카테고리의 다른 글
ENOENT (0) | 2015.12.30 |
---|---|
socket.io room join socket.id express api On Nodejs 5.1.0 + socket.io 1.3.7 (0) | 2015.12.17 |
socket.io 1.3.7 cluster On Nodejs 5.1.0 (0) | 2015.12.10 |
PM2 (0) | 2015.12.09 |
socket.io listen OR attach (0) | 2015.12.08 |