Nginx and proxy_pass

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I have a problem. I have 2 servers and 2 domains, I want to setup redirect from one to another. When I do it, I see 404 error no matter what I do. I don`t even see requests on the second server. I can ping/curl from first to the second server and get data.



centos-release-6-9.el6.12.3.i686
nginx version: nginx/1.10.2
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-17) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled



Nginx conf related to this task:



 location ~* ^/folder1/([^/]*)/([^/]*)/(.*).txt$ 
resolver 127.0.0.1 1.1.1.1;
proxy_intercept_errors on;
proxy_set_header Host domain1.com;
proxy_set_header Referrer domain1.com;
proxy_set_header User-Agent 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:58.0) Gecko/20100101 Firefox/58.0';
proxy_hide_header Content-Disposition;
proxy_pass http://domain2.com/folder2/$1/$2/$3.txt;
proxy_max_temp_file_size 0;
root $root_path;
error_page 404 = @fallback;



I thought problem-related to a resolver, I tried some combinations and it gives nothing. My experience is small.







share|improve this question



















  • Do you have a DNS resolver on 127.0.0.1 or 1.1.1.1? You should not normally need to set resolver in nginx unless you want the web server to use a different DNS resolver then the host it is running on.
    – GracefulRestart
    May 4 at 6:04










  • Isnt resolver is like DNS? I thought its like DNS servers. If I remove this string, I get 502 error from nginx on request.
    – Duna
    May 4 at 6:47











  • The nginx resolver setting tells nginx to use a specific DNS resolver, which would require that a DNS service is listening at the specified location. I just noticed that 1.1.1.1 does have a DNS service offered by cloudflare. Anything in either of the server's nginx logs for that 502 error? A 502 Bad Gateway error usually means that nginx had some sort of issue with the server listed in proxy_pass. Have you verified that you can reach domain2.com from the domain1.com server?
    – GracefulRestart
    May 4 at 7:09










  • error log: 2018/05/04 10:54:07 [error] 24144#0: *703343 no resolver defined to resolve domain2, client: myip, server: domain1, request: "GET /folder1/1/2/3.mp3 HTTP/1.1", host: "domain1", referrer: "http://domain1/myscript.php . It tells my nothing about what to do:( And yes, i can ping/curl from server1 to server2/domain2
    – Duna
    May 4 at 7:55















up vote
0
down vote

favorite












I have a problem. I have 2 servers and 2 domains, I want to setup redirect from one to another. When I do it, I see 404 error no matter what I do. I don`t even see requests on the second server. I can ping/curl from first to the second server and get data.



centos-release-6-9.el6.12.3.i686
nginx version: nginx/1.10.2
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-17) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled



Nginx conf related to this task:



 location ~* ^/folder1/([^/]*)/([^/]*)/(.*).txt$ 
resolver 127.0.0.1 1.1.1.1;
proxy_intercept_errors on;
proxy_set_header Host domain1.com;
proxy_set_header Referrer domain1.com;
proxy_set_header User-Agent 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:58.0) Gecko/20100101 Firefox/58.0';
proxy_hide_header Content-Disposition;
proxy_pass http://domain2.com/folder2/$1/$2/$3.txt;
proxy_max_temp_file_size 0;
root $root_path;
error_page 404 = @fallback;



I thought problem-related to a resolver, I tried some combinations and it gives nothing. My experience is small.







share|improve this question



















  • Do you have a DNS resolver on 127.0.0.1 or 1.1.1.1? You should not normally need to set resolver in nginx unless you want the web server to use a different DNS resolver then the host it is running on.
    – GracefulRestart
    May 4 at 6:04










  • Isnt resolver is like DNS? I thought its like DNS servers. If I remove this string, I get 502 error from nginx on request.
    – Duna
    May 4 at 6:47











  • The nginx resolver setting tells nginx to use a specific DNS resolver, which would require that a DNS service is listening at the specified location. I just noticed that 1.1.1.1 does have a DNS service offered by cloudflare. Anything in either of the server's nginx logs for that 502 error? A 502 Bad Gateway error usually means that nginx had some sort of issue with the server listed in proxy_pass. Have you verified that you can reach domain2.com from the domain1.com server?
    – GracefulRestart
    May 4 at 7:09










  • error log: 2018/05/04 10:54:07 [error] 24144#0: *703343 no resolver defined to resolve domain2, client: myip, server: domain1, request: "GET /folder1/1/2/3.mp3 HTTP/1.1", host: "domain1", referrer: "http://domain1/myscript.php . It tells my nothing about what to do:( And yes, i can ping/curl from server1 to server2/domain2
    – Duna
    May 4 at 7:55













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I have a problem. I have 2 servers and 2 domains, I want to setup redirect from one to another. When I do it, I see 404 error no matter what I do. I don`t even see requests on the second server. I can ping/curl from first to the second server and get data.



centos-release-6-9.el6.12.3.i686
nginx version: nginx/1.10.2
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-17) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled



Nginx conf related to this task:



 location ~* ^/folder1/([^/]*)/([^/]*)/(.*).txt$ 
resolver 127.0.0.1 1.1.1.1;
proxy_intercept_errors on;
proxy_set_header Host domain1.com;
proxy_set_header Referrer domain1.com;
proxy_set_header User-Agent 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:58.0) Gecko/20100101 Firefox/58.0';
proxy_hide_header Content-Disposition;
proxy_pass http://domain2.com/folder2/$1/$2/$3.txt;
proxy_max_temp_file_size 0;
root $root_path;
error_page 404 = @fallback;



I thought problem-related to a resolver, I tried some combinations and it gives nothing. My experience is small.







share|improve this question











I have a problem. I have 2 servers and 2 domains, I want to setup redirect from one to another. When I do it, I see 404 error no matter what I do. I don`t even see requests on the second server. I can ping/curl from first to the second server and get data.



centos-release-6-9.el6.12.3.i686
nginx version: nginx/1.10.2
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-17) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled



Nginx conf related to this task:



 location ~* ^/folder1/([^/]*)/([^/]*)/(.*).txt$ 
resolver 127.0.0.1 1.1.1.1;
proxy_intercept_errors on;
proxy_set_header Host domain1.com;
proxy_set_header Referrer domain1.com;
proxy_set_header User-Agent 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:58.0) Gecko/20100101 Firefox/58.0';
proxy_hide_header Content-Disposition;
proxy_pass http://domain2.com/folder2/$1/$2/$3.txt;
proxy_max_temp_file_size 0;
root $root_path;
error_page 404 = @fallback;



I thought problem-related to a resolver, I tried some combinations and it gives nothing. My experience is small.









share|improve this question










share|improve this question




share|improve this question









asked May 3 at 20:15









Duna

1




1











  • Do you have a DNS resolver on 127.0.0.1 or 1.1.1.1? You should not normally need to set resolver in nginx unless you want the web server to use a different DNS resolver then the host it is running on.
    – GracefulRestart
    May 4 at 6:04










  • Isnt resolver is like DNS? I thought its like DNS servers. If I remove this string, I get 502 error from nginx on request.
    – Duna
    May 4 at 6:47











  • The nginx resolver setting tells nginx to use a specific DNS resolver, which would require that a DNS service is listening at the specified location. I just noticed that 1.1.1.1 does have a DNS service offered by cloudflare. Anything in either of the server's nginx logs for that 502 error? A 502 Bad Gateway error usually means that nginx had some sort of issue with the server listed in proxy_pass. Have you verified that you can reach domain2.com from the domain1.com server?
    – GracefulRestart
    May 4 at 7:09










  • error log: 2018/05/04 10:54:07 [error] 24144#0: *703343 no resolver defined to resolve domain2, client: myip, server: domain1, request: "GET /folder1/1/2/3.mp3 HTTP/1.1", host: "domain1", referrer: "http://domain1/myscript.php . It tells my nothing about what to do:( And yes, i can ping/curl from server1 to server2/domain2
    – Duna
    May 4 at 7:55

















  • Do you have a DNS resolver on 127.0.0.1 or 1.1.1.1? You should not normally need to set resolver in nginx unless you want the web server to use a different DNS resolver then the host it is running on.
    – GracefulRestart
    May 4 at 6:04










  • Isnt resolver is like DNS? I thought its like DNS servers. If I remove this string, I get 502 error from nginx on request.
    – Duna
    May 4 at 6:47











  • The nginx resolver setting tells nginx to use a specific DNS resolver, which would require that a DNS service is listening at the specified location. I just noticed that 1.1.1.1 does have a DNS service offered by cloudflare. Anything in either of the server's nginx logs for that 502 error? A 502 Bad Gateway error usually means that nginx had some sort of issue with the server listed in proxy_pass. Have you verified that you can reach domain2.com from the domain1.com server?
    – GracefulRestart
    May 4 at 7:09










  • error log: 2018/05/04 10:54:07 [error] 24144#0: *703343 no resolver defined to resolve domain2, client: myip, server: domain1, request: "GET /folder1/1/2/3.mp3 HTTP/1.1", host: "domain1", referrer: "http://domain1/myscript.php . It tells my nothing about what to do:( And yes, i can ping/curl from server1 to server2/domain2
    – Duna
    May 4 at 7:55
















Do you have a DNS resolver on 127.0.0.1 or 1.1.1.1? You should not normally need to set resolver in nginx unless you want the web server to use a different DNS resolver then the host it is running on.
– GracefulRestart
May 4 at 6:04




Do you have a DNS resolver on 127.0.0.1 or 1.1.1.1? You should not normally need to set resolver in nginx unless you want the web server to use a different DNS resolver then the host it is running on.
– GracefulRestart
May 4 at 6:04












Isnt resolver is like DNS? I thought its like DNS servers. If I remove this string, I get 502 error from nginx on request.
– Duna
May 4 at 6:47





Isnt resolver is like DNS? I thought its like DNS servers. If I remove this string, I get 502 error from nginx on request.
– Duna
May 4 at 6:47













The nginx resolver setting tells nginx to use a specific DNS resolver, which would require that a DNS service is listening at the specified location. I just noticed that 1.1.1.1 does have a DNS service offered by cloudflare. Anything in either of the server's nginx logs for that 502 error? A 502 Bad Gateway error usually means that nginx had some sort of issue with the server listed in proxy_pass. Have you verified that you can reach domain2.com from the domain1.com server?
– GracefulRestart
May 4 at 7:09




The nginx resolver setting tells nginx to use a specific DNS resolver, which would require that a DNS service is listening at the specified location. I just noticed that 1.1.1.1 does have a DNS service offered by cloudflare. Anything in either of the server's nginx logs for that 502 error? A 502 Bad Gateway error usually means that nginx had some sort of issue with the server listed in proxy_pass. Have you verified that you can reach domain2.com from the domain1.com server?
– GracefulRestart
May 4 at 7:09












error log: 2018/05/04 10:54:07 [error] 24144#0: *703343 no resolver defined to resolve domain2, client: myip, server: domain1, request: "GET /folder1/1/2/3.mp3 HTTP/1.1", host: "domain1", referrer: "http://domain1/myscript.php . It tells my nothing about what to do:( And yes, i can ping/curl from server1 to server2/domain2
– Duna
May 4 at 7:55





error log: 2018/05/04 10:54:07 [error] 24144#0: *703343 no resolver defined to resolve domain2, client: myip, server: domain1, request: "GET /folder1/1/2/3.mp3 HTTP/1.1", host: "domain1", referrer: "http://domain1/myscript.php . It tells my nothing about what to do:( And yes, i can ping/curl from server1 to server2/domain2
– Duna
May 4 at 7:55











1 Answer
1






active

oldest

votes

















up vote
0
down vote













I just an idiot. I just changed conf part to:

proxy_set_header Host domain2.com;



And now it works. Thanks, GracefulRestart, I just googled this error and it clearly told me to use domain2 instead of domain1 in my config.






share|improve this answer





















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    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: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );








     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f441653%2fnginx-and-proxy-pass%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    I just an idiot. I just changed conf part to:

    proxy_set_header Host domain2.com;



    And now it works. Thanks, GracefulRestart, I just googled this error and it clearly told me to use domain2 instead of domain1 in my config.






    share|improve this answer

























      up vote
      0
      down vote













      I just an idiot. I just changed conf part to:

      proxy_set_header Host domain2.com;



      And now it works. Thanks, GracefulRestart, I just googled this error and it clearly told me to use domain2 instead of domain1 in my config.






      share|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        I just an idiot. I just changed conf part to:

        proxy_set_header Host domain2.com;



        And now it works. Thanks, GracefulRestart, I just googled this error and it clearly told me to use domain2 instead of domain1 in my config.






        share|improve this answer













        I just an idiot. I just changed conf part to:

        proxy_set_header Host domain2.com;



        And now it works. Thanks, GracefulRestart, I just googled this error and it clearly told me to use domain2 instead of domain1 in my config.







        share|improve this answer













        share|improve this answer



        share|improve this answer











        answered May 4 at 8:07









        Duna

        1




        1






















             

            draft saved


            draft discarded


























             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f441653%2fnginx-and-proxy-pass%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            Peggy Mitchell

            Palaiologos

            The Forum (Inglewood, California)