How to make an existing caching Nginx proxy use another proxy to bypass a firewall?How to set up Nginx as a caching reverse proxy?nginx reverse proxyNginx proxy_pass reverse proxying behind corporate firewallLoad Balancer and Proxy for Meteor not passing to 127.0.0.1 - Too Many Redirects?How to match string in URL using NginxSame location with different proxy urls nginxnginx proxy caching not workingCan't get nginx caching to works over https reverse proxyWhy does Nginx not just forward the POST request instead of 302Nginx caching reverse proxy with URL rewrite

What is wrong with this proof that symmetric matrices commute?

Cycle through MeshStyle directives in ListLinePlot

Someone whose aspirations exceed abilities or means

How to signal to my players that the following part is supposed to be played on fast forward?

Why would future John risk sending back a T-800 to save his younger self?

Is using haveibeenpwned to validate password strength rational?

Fixing obscure 8080 emulator bug?

What do abbreviations in movie scripts stand for?

Overlapping String-Blocks

Is the term 'open source' a trademark?

A curious prime counting approximation or just data overfitting?

Taxi Services at Didcot

How to hide an urban landmark?

Are there any important biographies of nobodies?

How to return a security deposit to a tenant

Second (easy access) account in case my bank screws up

Is it legal for a bar bouncer to conficaste a fake ID

What's up with this leaf?

What is the highest possible permanent AC at character creation?

How to tell your grandparent to not come to fetch you with their car?

Would the US government be able to hold control if all electronics were disabled for an indefinite amount of time?

Mobile App Appraisal

System.StringException: Unexpected end of expression

Recommended tools for graphs and charts



How to make an existing caching Nginx proxy use another proxy to bypass a firewall?


How to set up Nginx as a caching reverse proxy?nginx reverse proxyNginx proxy_pass reverse proxying behind corporate firewallLoad Balancer and Proxy for Meteor not passing to 127.0.0.1 - Too Many Redirects?How to match string in URL using NginxSame location with different proxy urls nginxnginx proxy caching not workingCan't get nginx caching to works over https reverse proxyWhy does Nginx not just forward the POST request instead of 302Nginx caching reverse proxy with URL rewrite






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








4















My question is about using Nginx as a proxy behind another proxy. (Somewhat confusing.)



I want to set up Nginx so it acts as a caching proxy server to an npm mirror. Here is the link:
http://eng.yammer.com/a-private-npm-cache/



On my local machine, which is not restricted by a firewall, the following configuration works fine:



proxy_cache_path /var/cache/npm/data levels=1:2 keys_zone=npm:20m max_size=1000m
inactive=365d;
proxy_temp_path /var/cache/npm/tmp;

server
listen 80;
server_name classen.abc.lan;
location /
proxy_pass http://registry.npmjs.org/;
proxy_cache npm;
proxy_cache_valid 200 302 365d;
proxy_cache_valid 404 1m;
sub_filter 'registry.npmjs.org' 'classen.abc.lan';
sub_filter_once off;
sub_filter_types application/json;




Now I want to apply it to a server that is behind an additional firewall. In the logs, I can confirm that it accesses the correct upstream IP, but the request fails because of the internal firewall.



We have one internal proxy, which I can use to bypass the firewall, for example:



$ curl http://registry.npmjs.org
curl: (7) couldn't connect to host
$ http_proxy=http://proxy.abc.lan:1234/ curl http://registry.npmjs.org
... succeeds ...


This trick does not work with Nginx, as it ignores the http_proxy environment variable. After reading the documentation, I still could not figure out how to modify the configuration, so that it can use the proxy internally.



Is it possible to combine both solutions? It is important that the caching still works, otherwise, you can just use the external mirror registry.npmjs.org directly.



Maybe, Nginx should use the internal proxy (proxy.abc.lan) as proxy_pass, but then how does the internal proxy know that the request should be sent to the external npm mirror (http://registry.npmjs.org)?



Update to Lukas answer



I tried Lukas solution:



rewrite ^(.*)$ "http://registry.npmjs.org$1" break;
proxy_pass http://proxy.abc.lan:1234;


The logs show that the URL is rewritten but it results in a redirect (triggered by curl classen.abc.lan/test-url):



2014/03/24 11:31:16 [notice] 13827#0: *2 rewritten redirect: "http://registry.npmjs.org/test-url", client: 172.18.40.33, server: classen.abc.lan, request: "GET /test-url HTTP/1.1", host: "classen.abc.lan"


The result of the curl call is not the expected JSON string from http://registry.npmjs.org but a html page generated by Nginx:



$ curl classen.abc.lan/test-url
<html>
<head><title>302 Found</title></head>
<body bgcolor="white">
<center><h1>302 Found</h1></center>
<hr><center>nginx/1.4.7</center>
</body>
</html>









share|improve this question






























    4















    My question is about using Nginx as a proxy behind another proxy. (Somewhat confusing.)



    I want to set up Nginx so it acts as a caching proxy server to an npm mirror. Here is the link:
    http://eng.yammer.com/a-private-npm-cache/



    On my local machine, which is not restricted by a firewall, the following configuration works fine:



    proxy_cache_path /var/cache/npm/data levels=1:2 keys_zone=npm:20m max_size=1000m
    inactive=365d;
    proxy_temp_path /var/cache/npm/tmp;

    server
    listen 80;
    server_name classen.abc.lan;
    location /
    proxy_pass http://registry.npmjs.org/;
    proxy_cache npm;
    proxy_cache_valid 200 302 365d;
    proxy_cache_valid 404 1m;
    sub_filter 'registry.npmjs.org' 'classen.abc.lan';
    sub_filter_once off;
    sub_filter_types application/json;




    Now I want to apply it to a server that is behind an additional firewall. In the logs, I can confirm that it accesses the correct upstream IP, but the request fails because of the internal firewall.



    We have one internal proxy, which I can use to bypass the firewall, for example:



    $ curl http://registry.npmjs.org
    curl: (7) couldn't connect to host
    $ http_proxy=http://proxy.abc.lan:1234/ curl http://registry.npmjs.org
    ... succeeds ...


    This trick does not work with Nginx, as it ignores the http_proxy environment variable. After reading the documentation, I still could not figure out how to modify the configuration, so that it can use the proxy internally.



    Is it possible to combine both solutions? It is important that the caching still works, otherwise, you can just use the external mirror registry.npmjs.org directly.



    Maybe, Nginx should use the internal proxy (proxy.abc.lan) as proxy_pass, but then how does the internal proxy know that the request should be sent to the external npm mirror (http://registry.npmjs.org)?



    Update to Lukas answer



    I tried Lukas solution:



    rewrite ^(.*)$ "http://registry.npmjs.org$1" break;
    proxy_pass http://proxy.abc.lan:1234;


    The logs show that the URL is rewritten but it results in a redirect (triggered by curl classen.abc.lan/test-url):



    2014/03/24 11:31:16 [notice] 13827#0: *2 rewritten redirect: "http://registry.npmjs.org/test-url", client: 172.18.40.33, server: classen.abc.lan, request: "GET /test-url HTTP/1.1", host: "classen.abc.lan"


    The result of the curl call is not the expected JSON string from http://registry.npmjs.org but a html page generated by Nginx:



    $ curl classen.abc.lan/test-url
    <html>
    <head><title>302 Found</title></head>
    <body bgcolor="white">
    <center><h1>302 Found</h1></center>
    <hr><center>nginx/1.4.7</center>
    </body>
    </html>









    share|improve this question


























      4












      4








      4


      1






      My question is about using Nginx as a proxy behind another proxy. (Somewhat confusing.)



      I want to set up Nginx so it acts as a caching proxy server to an npm mirror. Here is the link:
      http://eng.yammer.com/a-private-npm-cache/



      On my local machine, which is not restricted by a firewall, the following configuration works fine:



      proxy_cache_path /var/cache/npm/data levels=1:2 keys_zone=npm:20m max_size=1000m
      inactive=365d;
      proxy_temp_path /var/cache/npm/tmp;

      server
      listen 80;
      server_name classen.abc.lan;
      location /
      proxy_pass http://registry.npmjs.org/;
      proxy_cache npm;
      proxy_cache_valid 200 302 365d;
      proxy_cache_valid 404 1m;
      sub_filter 'registry.npmjs.org' 'classen.abc.lan';
      sub_filter_once off;
      sub_filter_types application/json;




      Now I want to apply it to a server that is behind an additional firewall. In the logs, I can confirm that it accesses the correct upstream IP, but the request fails because of the internal firewall.



      We have one internal proxy, which I can use to bypass the firewall, for example:



      $ curl http://registry.npmjs.org
      curl: (7) couldn't connect to host
      $ http_proxy=http://proxy.abc.lan:1234/ curl http://registry.npmjs.org
      ... succeeds ...


      This trick does not work with Nginx, as it ignores the http_proxy environment variable. After reading the documentation, I still could not figure out how to modify the configuration, so that it can use the proxy internally.



      Is it possible to combine both solutions? It is important that the caching still works, otherwise, you can just use the external mirror registry.npmjs.org directly.



      Maybe, Nginx should use the internal proxy (proxy.abc.lan) as proxy_pass, but then how does the internal proxy know that the request should be sent to the external npm mirror (http://registry.npmjs.org)?



      Update to Lukas answer



      I tried Lukas solution:



      rewrite ^(.*)$ "http://registry.npmjs.org$1" break;
      proxy_pass http://proxy.abc.lan:1234;


      The logs show that the URL is rewritten but it results in a redirect (triggered by curl classen.abc.lan/test-url):



      2014/03/24 11:31:16 [notice] 13827#0: *2 rewritten redirect: "http://registry.npmjs.org/test-url", client: 172.18.40.33, server: classen.abc.lan, request: "GET /test-url HTTP/1.1", host: "classen.abc.lan"


      The result of the curl call is not the expected JSON string from http://registry.npmjs.org but a html page generated by Nginx:



      $ curl classen.abc.lan/test-url
      <html>
      <head><title>302 Found</title></head>
      <body bgcolor="white">
      <center><h1>302 Found</h1></center>
      <hr><center>nginx/1.4.7</center>
      </body>
      </html>









      share|improve this question
















      My question is about using Nginx as a proxy behind another proxy. (Somewhat confusing.)



      I want to set up Nginx so it acts as a caching proxy server to an npm mirror. Here is the link:
      http://eng.yammer.com/a-private-npm-cache/



      On my local machine, which is not restricted by a firewall, the following configuration works fine:



      proxy_cache_path /var/cache/npm/data levels=1:2 keys_zone=npm:20m max_size=1000m
      inactive=365d;
      proxy_temp_path /var/cache/npm/tmp;

      server
      listen 80;
      server_name classen.abc.lan;
      location /
      proxy_pass http://registry.npmjs.org/;
      proxy_cache npm;
      proxy_cache_valid 200 302 365d;
      proxy_cache_valid 404 1m;
      sub_filter 'registry.npmjs.org' 'classen.abc.lan';
      sub_filter_once off;
      sub_filter_types application/json;




      Now I want to apply it to a server that is behind an additional firewall. In the logs, I can confirm that it accesses the correct upstream IP, but the request fails because of the internal firewall.



      We have one internal proxy, which I can use to bypass the firewall, for example:



      $ curl http://registry.npmjs.org
      curl: (7) couldn't connect to host
      $ http_proxy=http://proxy.abc.lan:1234/ curl http://registry.npmjs.org
      ... succeeds ...


      This trick does not work with Nginx, as it ignores the http_proxy environment variable. After reading the documentation, I still could not figure out how to modify the configuration, so that it can use the proxy internally.



      Is it possible to combine both solutions? It is important that the caching still works, otherwise, you can just use the external mirror registry.npmjs.org directly.



      Maybe, Nginx should use the internal proxy (proxy.abc.lan) as proxy_pass, but then how does the internal proxy know that the request should be sent to the external npm mirror (http://registry.npmjs.org)?



      Update to Lukas answer



      I tried Lukas solution:



      rewrite ^(.*)$ "http://registry.npmjs.org$1" break;
      proxy_pass http://proxy.abc.lan:1234;


      The logs show that the URL is rewritten but it results in a redirect (triggered by curl classen.abc.lan/test-url):



      2014/03/24 11:31:16 [notice] 13827#0: *2 rewritten redirect: "http://registry.npmjs.org/test-url", client: 172.18.40.33, server: classen.abc.lan, request: "GET /test-url HTTP/1.1", host: "classen.abc.lan"


      The result of the curl call is not the expected JSON string from http://registry.npmjs.org but a html page generated by Nginx:



      $ curl classen.abc.lan/test-url
      <html>
      <head><title>302 Found</title></head>
      <body bgcolor="white">
      <center><h1>302 Found</h1></center>
      <hr><center>nginx/1.4.7</center>
      </body>
      </html>






      nginx firewall proxy cache






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 24 '14 at 10:41







      Philipp Claßen

















      asked Mar 21 '14 at 18:11









      Philipp ClaßenPhilipp Claßen

      226416




      226416




















          3 Answers
          3






          active

          oldest

          votes


















          4














          The issue with Lukas's solution is HttpRewriteModule , which automatically turns everything with http(s) at the front into a 302.



          If you instead do the rewrite in two stages - the second one 'break' - it should work. e.g.



          rewrite ^(.*)$ "://registry.npmjs.org$1";
          rewrite ^(.*)$ "http$1" break;
          proxy_pass http://proxy.abc.lan:1234;


          I suspect there's a nicer way to do this, but it appears to work.






          share|improve this answer

























          • This really worked!!! I am using nginx as forward proxy behind a corporate proxy. My config: rewrite ^(.*)$ "://$http_host$uri$is_args$args" break; rewrite ^(.*)$ "http$uri$is_args$args" break; proxy_pass http://proxy.abc.lan:3128;

            – Prashant Borde
            Oct 1 '16 at 18:30







          • 1





            Should the first rewrite not "break"? Also, I think people would appreciate it if you can mention https proxy is not supported by Nginx.

            – blurrcat
            Oct 11 '17 at 5:40











          • @blurrcat you are right. In addition, it does not support reverse proxy to https website.

            – ipcjs
            Sep 28 '18 at 8:31


















          2














          RFC 2616, Section 5.1.2 states




          The absoluteURI form is REQUIRED when the request is being made to a proxy.
          [...]

          An example Request-Line would be:



           GET http://www.w3.org/pub/WWW/TheProject.html HTTP/1.1



          So what you are supposed to do is pass the request to the proxy with those modified directives:



          rewrite ^(.*)$ "http://registry.npmjs.org$1" break;
          proxy_pass http://proxy.abc.lan:1234;


          According to the nginx docs, using rewrite ... break; will force nginx to use the rewritten URI (now an absolute URI as the protocol requires) instead of trying to build it from the proxy_pass directive.






          share|improve this answer

























          • Thanks for your answer. Unfortunately, I could not get it to work. Maybe I am missing something. I edited my answer to show what I have tried.

            – Philipp Claßen
            Mar 24 '14 at 10:43


















          0














          I think it may be simpler than either of the examples above. They are using rewrite to rewrite the url, I think you can use proxy_pass but pass the url to the proxy setting the host header param to the location you want to go to. e.g.



          http {

          upstream corporate_proxy
          server web-proxy.mycorp.com:8080;


          server
          listen 80;
          server_name classen.abc.lan;
          location /
          proxy_pass_header on;
          proxy_set_header Host "registry.npmjs.org";
          proxy_pass http://corporate_proxy;
          proxy_cache npm;
          proxy_cache_valid 200 302 365d;
          proxy_cache_valid 404 1m;
          sub_filter 'registry.npmjs.org' 'classen.abc.lan';
          sub_filter_once off;
          sub_filter_types application/json;







          share|improve this answer























            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "2"
            ;
            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',
            autoActivateHeartbeat: false,
            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%2fserverfault.com%2fquestions%2f583743%2fhow-to-make-an-existing-caching-nginx-proxy-use-another-proxy-to-bypass-a-firewa%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            3 Answers
            3






            active

            oldest

            votes








            3 Answers
            3






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            4














            The issue with Lukas's solution is HttpRewriteModule , which automatically turns everything with http(s) at the front into a 302.



            If you instead do the rewrite in two stages - the second one 'break' - it should work. e.g.



            rewrite ^(.*)$ "://registry.npmjs.org$1";
            rewrite ^(.*)$ "http$1" break;
            proxy_pass http://proxy.abc.lan:1234;


            I suspect there's a nicer way to do this, but it appears to work.






            share|improve this answer

























            • This really worked!!! I am using nginx as forward proxy behind a corporate proxy. My config: rewrite ^(.*)$ "://$http_host$uri$is_args$args" break; rewrite ^(.*)$ "http$uri$is_args$args" break; proxy_pass http://proxy.abc.lan:3128;

              – Prashant Borde
              Oct 1 '16 at 18:30







            • 1





              Should the first rewrite not "break"? Also, I think people would appreciate it if you can mention https proxy is not supported by Nginx.

              – blurrcat
              Oct 11 '17 at 5:40











            • @blurrcat you are right. In addition, it does not support reverse proxy to https website.

              – ipcjs
              Sep 28 '18 at 8:31















            4














            The issue with Lukas's solution is HttpRewriteModule , which automatically turns everything with http(s) at the front into a 302.



            If you instead do the rewrite in two stages - the second one 'break' - it should work. e.g.



            rewrite ^(.*)$ "://registry.npmjs.org$1";
            rewrite ^(.*)$ "http$1" break;
            proxy_pass http://proxy.abc.lan:1234;


            I suspect there's a nicer way to do this, but it appears to work.






            share|improve this answer

























            • This really worked!!! I am using nginx as forward proxy behind a corporate proxy. My config: rewrite ^(.*)$ "://$http_host$uri$is_args$args" break; rewrite ^(.*)$ "http$uri$is_args$args" break; proxy_pass http://proxy.abc.lan:3128;

              – Prashant Borde
              Oct 1 '16 at 18:30







            • 1





              Should the first rewrite not "break"? Also, I think people would appreciate it if you can mention https proxy is not supported by Nginx.

              – blurrcat
              Oct 11 '17 at 5:40











            • @blurrcat you are right. In addition, it does not support reverse proxy to https website.

              – ipcjs
              Sep 28 '18 at 8:31













            4












            4








            4







            The issue with Lukas's solution is HttpRewriteModule , which automatically turns everything with http(s) at the front into a 302.



            If you instead do the rewrite in two stages - the second one 'break' - it should work. e.g.



            rewrite ^(.*)$ "://registry.npmjs.org$1";
            rewrite ^(.*)$ "http$1" break;
            proxy_pass http://proxy.abc.lan:1234;


            I suspect there's a nicer way to do this, but it appears to work.






            share|improve this answer















            The issue with Lukas's solution is HttpRewriteModule , which automatically turns everything with http(s) at the front into a 302.



            If you instead do the rewrite in two stages - the second one 'break' - it should work. e.g.



            rewrite ^(.*)$ "://registry.npmjs.org$1";
            rewrite ^(.*)$ "http$1" break;
            proxy_pass http://proxy.abc.lan:1234;


            I suspect there's a nicer way to do this, but it appears to work.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Sep 29 '18 at 21:15

























            answered Apr 20 '15 at 4:38









            james.haggertyjames.haggerty

            1413




            1413












            • This really worked!!! I am using nginx as forward proxy behind a corporate proxy. My config: rewrite ^(.*)$ "://$http_host$uri$is_args$args" break; rewrite ^(.*)$ "http$uri$is_args$args" break; proxy_pass http://proxy.abc.lan:3128;

              – Prashant Borde
              Oct 1 '16 at 18:30







            • 1





              Should the first rewrite not "break"? Also, I think people would appreciate it if you can mention https proxy is not supported by Nginx.

              – blurrcat
              Oct 11 '17 at 5:40











            • @blurrcat you are right. In addition, it does not support reverse proxy to https website.

              – ipcjs
              Sep 28 '18 at 8:31

















            • This really worked!!! I am using nginx as forward proxy behind a corporate proxy. My config: rewrite ^(.*)$ "://$http_host$uri$is_args$args" break; rewrite ^(.*)$ "http$uri$is_args$args" break; proxy_pass http://proxy.abc.lan:3128;

              – Prashant Borde
              Oct 1 '16 at 18:30







            • 1





              Should the first rewrite not "break"? Also, I think people would appreciate it if you can mention https proxy is not supported by Nginx.

              – blurrcat
              Oct 11 '17 at 5:40











            • @blurrcat you are right. In addition, it does not support reverse proxy to https website.

              – ipcjs
              Sep 28 '18 at 8:31
















            This really worked!!! I am using nginx as forward proxy behind a corporate proxy. My config: rewrite ^(.*)$ "://$http_host$uri$is_args$args" break; rewrite ^(.*)$ "http$uri$is_args$args" break; proxy_pass http://proxy.abc.lan:3128;

            – Prashant Borde
            Oct 1 '16 at 18:30






            This really worked!!! I am using nginx as forward proxy behind a corporate proxy. My config: rewrite ^(.*)$ "://$http_host$uri$is_args$args" break; rewrite ^(.*)$ "http$uri$is_args$args" break; proxy_pass http://proxy.abc.lan:3128;

            – Prashant Borde
            Oct 1 '16 at 18:30





            1




            1





            Should the first rewrite not "break"? Also, I think people would appreciate it if you can mention https proxy is not supported by Nginx.

            – blurrcat
            Oct 11 '17 at 5:40





            Should the first rewrite not "break"? Also, I think people would appreciate it if you can mention https proxy is not supported by Nginx.

            – blurrcat
            Oct 11 '17 at 5:40













            @blurrcat you are right. In addition, it does not support reverse proxy to https website.

            – ipcjs
            Sep 28 '18 at 8:31





            @blurrcat you are right. In addition, it does not support reverse proxy to https website.

            – ipcjs
            Sep 28 '18 at 8:31













            2














            RFC 2616, Section 5.1.2 states




            The absoluteURI form is REQUIRED when the request is being made to a proxy.
            [...]

            An example Request-Line would be:



             GET http://www.w3.org/pub/WWW/TheProject.html HTTP/1.1



            So what you are supposed to do is pass the request to the proxy with those modified directives:



            rewrite ^(.*)$ "http://registry.npmjs.org$1" break;
            proxy_pass http://proxy.abc.lan:1234;


            According to the nginx docs, using rewrite ... break; will force nginx to use the rewritten URI (now an absolute URI as the protocol requires) instead of trying to build it from the proxy_pass directive.






            share|improve this answer

























            • Thanks for your answer. Unfortunately, I could not get it to work. Maybe I am missing something. I edited my answer to show what I have tried.

              – Philipp Claßen
              Mar 24 '14 at 10:43















            2














            RFC 2616, Section 5.1.2 states




            The absoluteURI form is REQUIRED when the request is being made to a proxy.
            [...]

            An example Request-Line would be:



             GET http://www.w3.org/pub/WWW/TheProject.html HTTP/1.1



            So what you are supposed to do is pass the request to the proxy with those modified directives:



            rewrite ^(.*)$ "http://registry.npmjs.org$1" break;
            proxy_pass http://proxy.abc.lan:1234;


            According to the nginx docs, using rewrite ... break; will force nginx to use the rewritten URI (now an absolute URI as the protocol requires) instead of trying to build it from the proxy_pass directive.






            share|improve this answer

























            • Thanks for your answer. Unfortunately, I could not get it to work. Maybe I am missing something. I edited my answer to show what I have tried.

              – Philipp Claßen
              Mar 24 '14 at 10:43













            2












            2








            2







            RFC 2616, Section 5.1.2 states




            The absoluteURI form is REQUIRED when the request is being made to a proxy.
            [...]

            An example Request-Line would be:



             GET http://www.w3.org/pub/WWW/TheProject.html HTTP/1.1



            So what you are supposed to do is pass the request to the proxy with those modified directives:



            rewrite ^(.*)$ "http://registry.npmjs.org$1" break;
            proxy_pass http://proxy.abc.lan:1234;


            According to the nginx docs, using rewrite ... break; will force nginx to use the rewritten URI (now an absolute URI as the protocol requires) instead of trying to build it from the proxy_pass directive.






            share|improve this answer















            RFC 2616, Section 5.1.2 states




            The absoluteURI form is REQUIRED when the request is being made to a proxy.
            [...]

            An example Request-Line would be:



             GET http://www.w3.org/pub/WWW/TheProject.html HTTP/1.1



            So what you are supposed to do is pass the request to the proxy with those modified directives:



            rewrite ^(.*)$ "http://registry.npmjs.org$1" break;
            proxy_pass http://proxy.abc.lan:1234;


            According to the nginx docs, using rewrite ... break; will force nginx to use the rewritten URI (now an absolute URI as the protocol requires) instead of trying to build it from the proxy_pass directive.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Mar 23 '14 at 4:18

























            answered Mar 23 '14 at 4:12









            LukasLukas

            889512




            889512












            • Thanks for your answer. Unfortunately, I could not get it to work. Maybe I am missing something. I edited my answer to show what I have tried.

              – Philipp Claßen
              Mar 24 '14 at 10:43

















            • Thanks for your answer. Unfortunately, I could not get it to work. Maybe I am missing something. I edited my answer to show what I have tried.

              – Philipp Claßen
              Mar 24 '14 at 10:43
















            Thanks for your answer. Unfortunately, I could not get it to work. Maybe I am missing something. I edited my answer to show what I have tried.

            – Philipp Claßen
            Mar 24 '14 at 10:43





            Thanks for your answer. Unfortunately, I could not get it to work. Maybe I am missing something. I edited my answer to show what I have tried.

            – Philipp Claßen
            Mar 24 '14 at 10:43











            0














            I think it may be simpler than either of the examples above. They are using rewrite to rewrite the url, I think you can use proxy_pass but pass the url to the proxy setting the host header param to the location you want to go to. e.g.



            http {

            upstream corporate_proxy
            server web-proxy.mycorp.com:8080;


            server
            listen 80;
            server_name classen.abc.lan;
            location /
            proxy_pass_header on;
            proxy_set_header Host "registry.npmjs.org";
            proxy_pass http://corporate_proxy;
            proxy_cache npm;
            proxy_cache_valid 200 302 365d;
            proxy_cache_valid 404 1m;
            sub_filter 'registry.npmjs.org' 'classen.abc.lan';
            sub_filter_once off;
            sub_filter_types application/json;







            share|improve this answer



























              0














              I think it may be simpler than either of the examples above. They are using rewrite to rewrite the url, I think you can use proxy_pass but pass the url to the proxy setting the host header param to the location you want to go to. e.g.



              http {

              upstream corporate_proxy
              server web-proxy.mycorp.com:8080;


              server
              listen 80;
              server_name classen.abc.lan;
              location /
              proxy_pass_header on;
              proxy_set_header Host "registry.npmjs.org";
              proxy_pass http://corporate_proxy;
              proxy_cache npm;
              proxy_cache_valid 200 302 365d;
              proxy_cache_valid 404 1m;
              sub_filter 'registry.npmjs.org' 'classen.abc.lan';
              sub_filter_once off;
              sub_filter_types application/json;







              share|improve this answer

























                0












                0








                0







                I think it may be simpler than either of the examples above. They are using rewrite to rewrite the url, I think you can use proxy_pass but pass the url to the proxy setting the host header param to the location you want to go to. e.g.



                http {

                upstream corporate_proxy
                server web-proxy.mycorp.com:8080;


                server
                listen 80;
                server_name classen.abc.lan;
                location /
                proxy_pass_header on;
                proxy_set_header Host "registry.npmjs.org";
                proxy_pass http://corporate_proxy;
                proxy_cache npm;
                proxy_cache_valid 200 302 365d;
                proxy_cache_valid 404 1m;
                sub_filter 'registry.npmjs.org' 'classen.abc.lan';
                sub_filter_once off;
                sub_filter_types application/json;







                share|improve this answer













                I think it may be simpler than either of the examples above. They are using rewrite to rewrite the url, I think you can use proxy_pass but pass the url to the proxy setting the host header param to the location you want to go to. e.g.



                http {

                upstream corporate_proxy
                server web-proxy.mycorp.com:8080;


                server
                listen 80;
                server_name classen.abc.lan;
                location /
                proxy_pass_header on;
                proxy_set_header Host "registry.npmjs.org";
                proxy_pass http://corporate_proxy;
                proxy_cache npm;
                proxy_cache_valid 200 302 365d;
                proxy_cache_valid 404 1m;
                sub_filter 'registry.npmjs.org' 'classen.abc.lan';
                sub_filter_once off;
                sub_filter_types application/json;








                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Oct 28 '15 at 8:45









                Mark DMark D

                11615




                11615



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Server Fault!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f583743%2fhow-to-make-an-existing-caching-nginx-proxy-use-another-proxy-to-bypass-a-firewa%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







                    Popular posts from this blog

                    Club Baloncesto Breogán Índice Historia | Pavillón | Nome | O Breogán na cultura popular | Xogadores | Adestradores | Presidentes | Palmarés | Historial | Líderes | Notas | Véxase tamén | Menú de navegacióncbbreogan.galCadroGuía oficial da ACB 2009-10, páxina 201Guía oficial ACB 1992, páxina 183. Editorial DB.É de 6.500 espectadores sentados axeitándose á última normativa"Estudiantes Junior, entre as mellores canteiras"o orixinalHemeroteca El Mundo Deportivo, 16 setembro de 1970, páxina 12Historia do BreogánAlfredo Pérez, o último canoneiroHistoria C.B. BreogánHemeroteca de El Mundo DeportivoJimmy Wright, norteamericano do Breogán deixará Lugo por ameazas de morteResultados de Breogán en 1986-87Resultados de Breogán en 1990-91Ficha de Velimir Perasović en acb.comResultados de Breogán en 1994-95Breogán arrasa al Barça. "El Mundo Deportivo", 27 de setembro de 1999, páxina 58CB Breogán - FC BarcelonaA FEB invita a participar nunha nova Liga EuropeaCharlie Bell na prensa estatalMáximos anotadores 2005Tempada 2005-06 : Tódolos Xogadores da Xornada""Non quero pensar nunha man negra, mais pregúntome que está a pasar""o orixinalRaúl López, orgulloso dos xogadores, presume da boa saúde económica do BreogánJulio González confirma que cesa como presidente del BreogánHomenaxe a Lisardo GómezA tempada do rexurdimento celesteEntrevista a Lisardo GómezEl COB dinamita el Pazo para forzar el quinto (69-73)Cafés Candelas, patrocinador del CB Breogán"Suso Lázare, novo presidente do Breogán"o orixinalCafés Candelas Breogán firma el mayor triunfo de la historiaEl Breogán realizará 17 homenajes por su cincuenta aniversario"O Breogán honra ao seu fundador e primeiro presidente"o orixinalMiguel Giao recibiu a homenaxe do PazoHomenaxe aos primeiros gladiadores celestesO home que nos amosa como ver o Breo co corazónTita Franco será homenaxeada polos #50anosdeBreoJulio Vila recibirá unha homenaxe in memoriam polos #50anosdeBreo"O Breogán homenaxeará aos seus aboados máis veteráns"Pechada ovación a «Capi» Sanmartín e Ricardo «Corazón de González»Homenaxe por décadas de informaciónPaco García volve ao Pazo con motivo do 50 aniversario"Resultados y clasificaciones""O Cafés Candelas Breogán, campión da Copa Princesa""O Cafés Candelas Breogán, equipo ACB"C.B. Breogán"Proxecto social"o orixinal"Centros asociados"o orixinalFicha en imdb.comMario Camus trata la recuperación del amor en 'La vieja música', su última película"Páxina web oficial""Club Baloncesto Breogán""C. B. Breogán S.A.D."eehttp://www.fegaba.com

                    Vilaño, A Laracha Índice Patrimonio | Lugares e parroquias | Véxase tamén | Menú de navegación43°14′52″N 8°36′03″O / 43.24775, -8.60070

                    Cegueira Índice Epidemioloxía | Deficiencia visual | Tipos de cegueira | Principais causas de cegueira | Tratamento | Técnicas de adaptación e axudas | Vida dos cegos | Primeiros auxilios | Crenzas respecto das persoas cegas | Crenzas das persoas cegas | O neno deficiente visual | Aspectos psicolóxicos da cegueira | Notas | Véxase tamén | Menú de navegación54.054.154.436928256blindnessDicionario da Real Academia GalegaPortal das Palabras"International Standards: Visual Standards — Aspects and Ranges of Vision Loss with Emphasis on Population Surveys.""Visual impairment and blindness""Presentan un plan para previr a cegueira"o orixinalACCDV Associació Catalana de Cecs i Disminuïts Visuals - PMFTrachoma"Effect of gene therapy on visual function in Leber's congenital amaurosis"1844137110.1056/NEJMoa0802268Cans guía - os mellores amigos dos cegosArquivadoEscola de cans guía para cegos en Mortágua, PortugalArquivado"Tecnología para ciegos y deficientes visuales. Recopilación de recursos gratuitos en la Red""Colorino""‘COL.diesis’, escuchar los sonidos del color""COL.diesis: Transforming Colour into Melody and Implementing the Result in a Colour Sensor Device"o orixinal"Sistema de desarrollo de sinestesia color-sonido para invidentes utilizando un protocolo de audio""Enseñanza táctil - geometría y color. Juegos didácticos para niños ciegos y videntes""Sistema Constanz"L'ocupació laboral dels cecs a l'Estat espanyol està pràcticament equiparada a la de les persones amb visió, entrevista amb Pedro ZuritaONCE (Organización Nacional de Cegos de España)Prevención da cegueiraDescrición de deficiencias visuais (Disc@pnet)Braillín, un boneco atractivo para calquera neno, con ou sen discapacidade, que permite familiarizarse co sistema de escritura e lectura brailleAxudas Técnicas36838ID00897494007150-90057129528256DOID:1432HP:0000618D001766C10.597.751.941.162C97109C0155020