{"id":536,"date":"2016-12-29T10:40:49","date_gmt":"2016-12-29T05:10:49","guid":{"rendered":"http:\/\/www.cyberaka.com\/?p=536"},"modified":"2018-02-24T08:21:30","modified_gmt":"2018-02-24T02:51:30","slug":"using-nginx-for-proxy-pass","status":"publish","type":"post","link":"https:\/\/www.cyberaka.com\/?p=536","title":{"rendered":"Using NGINX for Proxy Pass"},"content":{"rendered":"<p>Lets say I have two servers running on my laptop<br \/>\n1. http:\/\/localhost:3000 &#8211; This is the UI<br \/>\n2. http:\/\/localhost:4000 &#8211; This is the web services API<\/p>\n<p>So now I need to setup something like this:<br \/>\n1. http:\/\/localhost\/ &#8211; This should point to UI<br \/>\n2. http:\/\/localhost\/api\/ &#8211; This should point to web services API<\/p>\n<p>To set this up I have used NGINX and added this section in the &#8220;server&#8221; section of the nginx.conf file. On my Mac system this file is located at: \/usr\/local\/etc\/nginx\/nginx.conf<\/p>\n<p>location \/api\/ {<br \/>\nproxy_set_header X-Forwarded-Host $host;<br \/>\nproxy_set_header X-Forwarded-Server $host;<br \/>\nproxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;<br \/>\nproxy_pass http:\/\/localhost:4000\/;<br \/>\n}<\/p>\n<p>location \/ {<br \/>\nproxy_set_header X-Forwarded-Host $host;<br \/>\nproxy_set_header X-Forwarded-Server $host;<br \/>\nproxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;<br \/>\nproxy_pass http:\/\/localhost:3000\/;<br \/>\n}<\/p>\n<p>To reload NGINX I use the &#8220;-s reload&#8221; parameter for nginx. On my Mac I execute this command:<br \/>\n\/usr\/local\/Cellar\/nginx\/1.10.0\/bin\/nginx -s reload<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Lets say I have two servers running on my laptop 1. http:\/\/localhost:3000 &#8211; This is the UI 2. http:\/\/localhost:4000 &#8211; This is the web services API So now I need to setup something like this: 1. http:\/\/localhost\/ &#8211; This should point to UI 2. http:\/\/localhost\/api\/ &#8211; This should point to web services API To set [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[35,23,24],"tags":[],"class_list":["post-536","post","type-post","status-publish","format-standard","hentry","category-mac-os","category-programming","category-tips-and-tricks"],"_links":{"self":[{"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=\/wp\/v2\/posts\/536","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=536"}],"version-history":[{"count":2,"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=\/wp\/v2\/posts\/536\/revisions"}],"predecessor-version":[{"id":628,"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=\/wp\/v2\/posts\/536\/revisions\/628"}],"wp:attachment":[{"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=536"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=536"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=536"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}