<html><head></head><body><div style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:16px;"><div style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:16px;"><div></div>
        <div>FYI - I believe I figured it out. Suggestions welcomed. Here is what I did:</div><div><br></div><div>On the frontend: Instead of doing GETs and POSTs to "<span><span>api.anothersite.com</span></span>/api/messages" I now do the call to "<span><span>mysite.com/api/messages</span></span>"</div><div><br></div><div>On the backend: added an additional "location" similar to:<br></div><div><br></div><div><div><span> location /api/messages {</span></div><div>    # the backend server<br></div><span>    proxy_pass http://localhost:50010/api/messages/;<br> }<br></span><br></div><div><br></div>
        
        </div><div id="ydp4f2c199yahoo_quoted_3364528099" class="ydp4f2c199yahoo_quoted">
            <div style="font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:13px;color:#26282a;">
                <div>----- Forwarded Message -----</div><div><br></div>
                <div><div id="ydp4f2c199yiv8732191886"><div><div style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:16px;"><div style="font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:13px;color:#26282a;">I would like to hide a backend API REST server from public view and have it accessed from frontend web server locally/internally. Is this possible? Below are my setup and configs: <br clear="none"><div><div id="ydp4f2c199yiv8732191886ydp904295bdyiv4988927207"><div><div style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:16px;"><div><span><br clear="none">angular/nodejs frontend app, say it is "mysite.com" running on server at 127.0.0.1:51910<br clear="none"><br clear="none">nodejs backend app, say it is "api.anothersite.com" running on server at 127.00.0.1:50010<br clear="none"><br clear="none">nginx(open source) listens for the server_name/domain and does a proxy_pass to the host/port listed above <br clear="none"><br clear="none">I currently can communicate back and forth with GET and POST requests and JSON responses.<br clear="none"><br clear="none">So far everything is great.<br clear="none"><br clear="none">However, beside just using CORS, I would now like to secure/hide "api.anothersite.com" from the public and just allow "mysite.com" to access 127.0.0.1:50010 internally instead of "api.anothersite.com" <br clear="none"><br clear="none">Can this be done via nginx?<div class="ydp4f2c199yiv8732191886yqt6860422173" id="ydp4f2c199yiv8732191886yqtfd94143"><br clear="none"><br clear="none">   server {<br clear="none">           server_name api.anothersite.com;<br clear="none">  <br clear="none">           listen 443 ssl;<br clear="none">           ssl_certificate /etc/letsencrypt/live/anothersite.com/fullchain.pem; <br clear="none">           ssl_certificate_key /etc/letsencrypt/live/anothersite.com/privkey.pem; <br clear="none">           include /etc/letsencrypt/options-ssl-nginx.conf; <br clear="none">           ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;<br clear="none">   <br clear="none">      location / {<br clear="none">              #allow xx.xx.xx.xx;<br clear="none">              #allow 127.0.0.1;<br clear="none">              #deny all;<br clear="none">              proxy_pass http://127.0.0.1:50010;<br clear="none"> <br clear="none">              proxy_http_version 1.1;<br clear="none">              proxy_set_header Upgrade $http_upgrade;<br clear="none">              proxy_set_header Connection 'upgrade';<br clear="none">              proxy_set_header Host $host;<br clear="none">              proxy_cache_bypass $http_upgrade;<br clear="none">          }<br clear="none">  }<br clear="none"><br clear="none">   server {<br clear="none">       server_name mysite.com www.mysite.com;<br clear="none">  <br clear="none">       location / {<br clear="none">  <br clear="none">      proxy_http_version 1.1;<br clear="none">            proxy_pass http://localhost:51910;<br clear="none">            proxy_set_header Upgrade $http_upgrade;<br clear="none">            proxy_set_header Connection 'upgrade';<br clear="none">           # proxy_set_header Host $host;<br clear="none">           proxy_set_header Host mysite.com;<br clear="none">           proxy_cache_bypass $http_upgrade;<br clear="none">           proxy_pass_request_headers on;<br clear="none">      }<br clear="none"> <br clear="none">      #error_page  404              /404.html;<br clear="none"> <br clear="none">      # redirect server error pages to the static page /50x.html<br clear="none">      #<br clear="none">      error_page   500 502 503 504  /50x.html;<br clear="none">      location = /50x.html {<br clear="none">          root   /usr/share/nginx/html;<br clear="none">      }<br clear="none"> <br clear="none">      listen 443 ssl; <br clear="none">      ssl_certificate /etc/letsencrypt/live/mysite.com/fullchain.pem; <br clear="none">      ssl_certificate_key /etc/letsencrypt/live/mysite.com/privkey.pem; <br clear="none">      include /etc/letsencrypt/options-ssl-nginx.conf; <br clear="none">      ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; <br clear="none">  }<br clear="none"> <br clear="none">  server {<br clear="none">      if ($host = www.mysite.com) {<br clear="none">          return 301 https://$host$request_uri;<br clear="none">      } <br clear="none"> <br clear="none">      if ($host = mysite.com) {<br clear="none">          return 301 https://$host$request_uri;<br clear="none">      } <br clear="none"> <br clear="none">      listen       80;<br clear="none">      server_name mysite.com www.mysite.com;<br clear="none">      return 404; <br clear="none">  }</div></span><div class="ydp4f2c199yiv8732191886yqt6860422173" id="ydp4f2c199yiv8732191886yqtfd93068"><br clear="none"></div></div></div></div></div></div><div class="ydp4f2c199yiv8732191886yqt6860422173" id="ydp4f2c199yiv8732191886yqtfd01479">
            </div></div><div class="ydp4f2c199yiv8732191886yqt6860422173" id="ydp4f2c199yiv8732191886yqtfd42814"><div class="ydp4f2c199yiv8732191886ydp904295bdyahoo_quoted" id="ydp4f2c199yiv8732191886ydp904295bdyahoo_quoted_2800245339">
        </div></div></div></div></div></div>
            </div>
        </div></div></body></html>