{"id":459,"date":"2019-04-28T12:30:11","date_gmt":"2019-04-28T12:30:11","guid":{"rendered":"http:\/\/emacslisp.com\/?p=459"},"modified":"2019-04-28T12:32:04","modified_gmt":"2019-04-28T12:32:04","slug":"nginx-reverse-proxy-as-load-balance-in-ubuntu","status":"publish","type":"post","link":"http:\/\/emacslisp.com\/?p=459","title":{"rendered":"Nginx &#8211; reverse proxy as load-balance in ubuntu"},"content":{"rendered":"<p>1. install nginx in ubuntu<\/p>\n<pre lang=\"bash\" line=\"1\">\r\n$ sudo apt install ngnix\r\n<\/pre>\n<p>2. print ngnix conf path<\/p>\n<pre lang=\"bash\" line=\"1\">\r\n$ sudo ngnix -t\r\n<\/pre>\n<p>3. create node.conf, in nginx.conf, it would load all file matched *.conf under conf.d\/<\/p>\n<pre lang=\"bash\" line=\"1\">\r\n$ touch \/etc\/nginx\/conf.d\/\r\n$ vim \/etc\/nginx\/conf.d\/node.conf\r\n<\/pre>\n<p>4. node.conf file context.<br \/>\nit is best to keep X-Real-IP and X-Forwarded-For, because in node.js app, it would record client&#8217;s ip address into log<\/p>\n<pre lang=\"conf\" line=\"1\">\r\nupstream nodeserver {\r\n   server localhost:3085;\r\n}\r\n\r\nserver {\r\n   listen 8080;\r\n   server_name linode.emacslisp.com;\r\n   \r\n   location \/test {\r\n       proxy_pass http:\/\/nodeserver;   \r\n       proxy_set_header Host $host;\r\n       proxy_set_header X-Real-IP $remote_addr;\r\n       proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;\r\n       proxy_redirect     off;\r\n       proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;\r\n       proxy_max_temp_file_size 0;\r\n       proxy_connect_timeout      90;\r\n       proxy_send_timeout         90;\r\n       proxy_read_timeout         90;\r\n       proxy_buffer_size          4k;\r\n       proxy_buffers              4 32k;\r\n       proxy_busy_buffers_size    64k;\r\n       proxy_temp_file_write_size 64k;       \r\n   }\r\n}\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>1. install nginx in ubuntu $ sudo apt install ngnix 2. print ngnix conf path $ sudo ngnix -t 3. create node.conf, in nginx.conf, it would load all file matched *.conf under conf.d\/ $ 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, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-459","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"http:\/\/emacslisp.com\/index.php?rest_route=\/wp\/v2\/posts\/459","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/emacslisp.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/emacslisp.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/emacslisp.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/emacslisp.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=459"}],"version-history":[{"count":4,"href":"http:\/\/emacslisp.com\/index.php?rest_route=\/wp\/v2\/posts\/459\/revisions"}],"predecessor-version":[{"id":463,"href":"http:\/\/emacslisp.com\/index.php?rest_route=\/wp\/v2\/posts\/459\/revisions\/463"}],"wp:attachment":[{"href":"http:\/\/emacslisp.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=459"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/emacslisp.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=459"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/emacslisp.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=459"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}