2.5.Node + Nginx
http { upstream node_server_pool { server 192.168.0.100:8080 weight=2; # 2/6次 server 192.168.0.101:8080 weight=3; # 3/6次 server 192.168.0.102:8080 weight=1; # 1/6次 } server{ listen 80; server_name localhost; location / { proxy_pass http://node_server_pool; } }
sudo apt-get update sudo apt-get install nginxsudo nano /etc/nginx/nginx.conf worker_processes 1; events { worker_connections 1024; } http { upstream node_server_pool { server localhost:3001 max_fails=1; server localhost:3000 max_fails=1; } server{ listen 80; server_name localhost; location / { proxy_pass http://node_server_pool; } } }
# Expire rules for static content # cache.appcache, your document html and data location ~* \.(?:manifest|appcache|html?|xml|json)$ { expires -1; # access_log logs/static.log; # I don't usually include a static log } # Feed location ~* \.(?:rss|atom)$ { expires 1h; add_header Cache-Control "public"; } # Media: images, icons, video, audio, HTC location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ { expires 1M; access_log off; add_header Cache-Control "public"; } # CSS and Javascript location ~* \.(?:css|js)$ { expires 1y; access_log off; add_header Cache-Control "public"; }
Last updated