1. install nginx in ubuntu
1 | $ sudo apt install ngnix |
2. print ngnix conf path
1 | $ sudo ngnix -t |
3. create node.conf, in nginx.conf, it would load all file matched *.conf under conf.d/
1 2 | $ touch /etc/nginx/conf.d/ $ vim /etc/nginx/conf.d/node.conf |
4. node.conf file context.
it is best to keep X-Real-IP and X-Forwarded-For, because in node.js app, it would record client’s ip address into log
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | upstream nodeserver {
server localhost:3085;
}
server {
listen 8080;
server_name linode.emacslisp.com;
location /test {
proxy_pass http://nodeserver;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect off;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_max_temp_file_size 0;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}
} |