Proxy through multiple VMs











up vote
0
down vote

favorite












I have an API hosted on a Virtual Box on Azure VM.



The VM is only allowed to be accessible from another VM (specific IP) not on same VPC (it is EC2 VM). Still I cannot call the API from the EC2 VM, I need to proxy to make it done.



I want to be able to call the API from my local laptop by proxy through the EC2 VM and the Azure VM to get to the API in the Virtual Box.



Right now when I use the following command from within the EC2 VM to proxy to the Azure VM I am then able to call the API from EC2 VM



ssh -N -L .. etc



So now I am trying to also proxy through the EC2 to call the API but it is not working.



Lets assume




  • API URL is : http://1.2.3.4:50100/api/

  • Azure VM ip : 2.3.4.5

  • EC2 VM ip : 3.4.5.6


What I am doing now :



In the Ec2 VM



ssh -N -L 3000:1.2.3.4:50100 -i <key> <user>2.3.4.5



This allows me to call the API from EC2 VM http://172.0.0.1:3000/api/



While the proxy is running in the EC2 VM I also run this command on my laptop



ssh -N -L 1240:172.0.0.1:3000 -i <key> <user>@3.4.5.6



My assumption that calling http://172.0.0.1:1240/api/ from my laptop will forward to the EC2 VM http://172.0.0.1:3000/api/ which in turn will forward to http://1.2.3.4:50100/api/ eventually.



What I am doing wrong here ?










share|improve this question


























    up vote
    0
    down vote

    favorite












    I have an API hosted on a Virtual Box on Azure VM.



    The VM is only allowed to be accessible from another VM (specific IP) not on same VPC (it is EC2 VM). Still I cannot call the API from the EC2 VM, I need to proxy to make it done.



    I want to be able to call the API from my local laptop by proxy through the EC2 VM and the Azure VM to get to the API in the Virtual Box.



    Right now when I use the following command from within the EC2 VM to proxy to the Azure VM I am then able to call the API from EC2 VM



    ssh -N -L .. etc



    So now I am trying to also proxy through the EC2 to call the API but it is not working.



    Lets assume




    • API URL is : http://1.2.3.4:50100/api/

    • Azure VM ip : 2.3.4.5

    • EC2 VM ip : 3.4.5.6


    What I am doing now :



    In the Ec2 VM



    ssh -N -L 3000:1.2.3.4:50100 -i <key> <user>2.3.4.5



    This allows me to call the API from EC2 VM http://172.0.0.1:3000/api/



    While the proxy is running in the EC2 VM I also run this command on my laptop



    ssh -N -L 1240:172.0.0.1:3000 -i <key> <user>@3.4.5.6



    My assumption that calling http://172.0.0.1:1240/api/ from my laptop will forward to the EC2 VM http://172.0.0.1:3000/api/ which in turn will forward to http://1.2.3.4:50100/api/ eventually.



    What I am doing wrong here ?










    share|improve this question
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I have an API hosted on a Virtual Box on Azure VM.



      The VM is only allowed to be accessible from another VM (specific IP) not on same VPC (it is EC2 VM). Still I cannot call the API from the EC2 VM, I need to proxy to make it done.



      I want to be able to call the API from my local laptop by proxy through the EC2 VM and the Azure VM to get to the API in the Virtual Box.



      Right now when I use the following command from within the EC2 VM to proxy to the Azure VM I am then able to call the API from EC2 VM



      ssh -N -L .. etc



      So now I am trying to also proxy through the EC2 to call the API but it is not working.



      Lets assume




      • API URL is : http://1.2.3.4:50100/api/

      • Azure VM ip : 2.3.4.5

      • EC2 VM ip : 3.4.5.6


      What I am doing now :



      In the Ec2 VM



      ssh -N -L 3000:1.2.3.4:50100 -i <key> <user>2.3.4.5



      This allows me to call the API from EC2 VM http://172.0.0.1:3000/api/



      While the proxy is running in the EC2 VM I also run this command on my laptop



      ssh -N -L 1240:172.0.0.1:3000 -i <key> <user>@3.4.5.6



      My assumption that calling http://172.0.0.1:1240/api/ from my laptop will forward to the EC2 VM http://172.0.0.1:3000/api/ which in turn will forward to http://1.2.3.4:50100/api/ eventually.



      What I am doing wrong here ?










      share|improve this question













      I have an API hosted on a Virtual Box on Azure VM.



      The VM is only allowed to be accessible from another VM (specific IP) not on same VPC (it is EC2 VM). Still I cannot call the API from the EC2 VM, I need to proxy to make it done.



      I want to be able to call the API from my local laptop by proxy through the EC2 VM and the Azure VM to get to the API in the Virtual Box.



      Right now when I use the following command from within the EC2 VM to proxy to the Azure VM I am then able to call the API from EC2 VM



      ssh -N -L .. etc



      So now I am trying to also proxy through the EC2 to call the API but it is not working.



      Lets assume




      • API URL is : http://1.2.3.4:50100/api/

      • Azure VM ip : 2.3.4.5

      • EC2 VM ip : 3.4.5.6


      What I am doing now :



      In the Ec2 VM



      ssh -N -L 3000:1.2.3.4:50100 -i <key> <user>2.3.4.5



      This allows me to call the API from EC2 VM http://172.0.0.1:3000/api/



      While the proxy is running in the EC2 VM I also run this command on my laptop



      ssh -N -L 1240:172.0.0.1:3000 -i <key> <user>@3.4.5.6



      My assumption that calling http://172.0.0.1:1240/api/ from my laptop will forward to the EC2 VM http://172.0.0.1:3000/api/ which in turn will forward to http://1.2.3.4:50100/api/ eventually.



      What I am doing wrong here ?







      proxy portforwarding






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 7 at 8:57









      Ahmad Alkhawaja

      245923




      245923





























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53186187%2fproxy-through-multiple-vms%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53186187%2fproxy-through-multiple-vms%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          這個網誌中的熱門文章

          Tangent Lines Diagram Along Smooth Curve

          Yusuf al-Mu'taman ibn Hud

          Zucchini