-
Notifications
You must be signed in to change notification settings - Fork 3
Configure Nginx
Nginx will listen to PORT 80 by default. We need configure Nginx to listen to PORTs opened by Node server. To setup the node server, we follow the formal procedures of nginx.
Note : Following code is working on Centos 6. Please check the code before using it in debian or ubuntu.
In centos, '/etc/nginx/nginx.conf' is the location of nginx configuration file.
To edit this file
# vim /etc/nginx/nginx.conf
In the file nginx.conf, set worker_process number to number of processor cores available on your system.
To get the no. of system cores try following command
# grep processor /proc/cpuinfo | wc -l
Then set the worker_connection to the value obtained from following command
# ulimit -n
To optimize the connection add the following 4 lines inside the http block of nginx.conf ( Comment out keepalive_timeout line if exsits )
http{
...
client_body_timeout 12;
client_header_timeout 12;
keepalive_timeout 15;
send_timeout 10;
...
}
Then turn on the gzip feature by adding following 5 line to the nginx.conf file inside http block ( Probably the code in file will be commented. )
http{
...
gzip on;
gzip_comp_level 2;
gzip_min_length 1000;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain application/x-javascript text/xml text/css application/xml;
...
}
As to include our private configurations to nginx, add the following line as last line to http block of nginx.conf
http{
...
include /srv/nginx/*.conf;
}
Thus general nginx is configured.
Note : Don't restart server unless the nginx is configured for node server since the configuration uses some node configuration paths
The Mozilla Foundation invites all others who support the principles of the Mozilla Manifesto to join with us, and to find new ways to make this vision of the Internet a reality.