HowTo Use Nginx to deliver nodejs pages
The nodejs integrated webserver does not scale very well under high load especially if you want to use https.
For this usage case you can simply put nginx in front of nodejs. nginx is much more stable in handling encrypted connections and performes very well even under a huge amount of requests:
server {
listen 443 ssl;
server_tokens off;
ssl_certificate /etc/nginx/yourpage.crt;
ssl_certificate_key /etc/nginx/yourpage.key;
ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:100m;
ssl_session_timeout 10m;
access_log off;
error_log /dev/null;
location / {
proxy_redirect off;
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 Connection "";
proxy_http_version 1.1;
proxy_pass http://your-nodejs-server:port;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
Written by Markus Perl
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Nginx
Authors
reiaguilera
279.6K
jamesdullaghan
90.19K
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#