Nginx Proxy pass to s3 for js files returns 400 Bad request [closed]












-1















Below is my nginx configuration.



    server_name  myserver.com;

location ~ /(in|sr)/(en|tm)/(.+.(css|js)) {
proxy_set_header Host http://mybucketabc.s3.amazonaws.com;

proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header Authorization '';
proxy_hide_header x-amz-id-2;
proxy_hide_header x-amz-request-id;
proxy_hide_header x-amz-meta-server-side-encryption;
proxy_hide_header x-amz-server-side-encryption;
proxy_hide_header Set-Cookie;
proxy_ignore_headers Set-Cookie;
proxy_intercept_errors on;
add_header Cache-Control max-age=31536000;

rewrite ^/(in|sr)/(en|tm)/(.*) /$1/$2/$3 break;
proxy_pass http://mybucketabc.s3.amazonaws.com;
}


When I try to access http://myserver.com/in/en/main.9bd9926d.js, I'm getting "400 Bad Request"



But directly accessing http://mybucketabc.s3.amazonaws.com/in/en/main.9bd9926d.js works fine.



I've similar proxy pass rules for html and svg files, both works fine but requests to .js files always throws "400 Bad Request".



Any help is really appreciated.










share|improve this question













closed as off-topic by Makyen, jww, Vega, Mike M., Pearly Spencer Nov 29 '18 at 11:29


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Questions about general computing hardware and software are off-topic for Stack Overflow unless they directly involve tools used primarily for programming. You may be able to get help on Super User." – Makyen, jww, Mike M., Pearly Spencer

If this question can be reworded to fit the rules in the help center, please edit the question.

















  • Have you tried making a simpler location with the bare minimum of directives and slowly adding back in directives? I do something similar with just proxy_pass, proxy_intercept_errors, and recursive_error_pages

    – Shawn C.
    Nov 28 '18 at 21:17











  • That attempt helped me to resolve the issue. It was happening due wrong Host. proxy_set_header Host mybucketabc.s3.amazonaws.com; "http://" got added in the host by mistake. Thanks a lot.

    – Sunil
    Nov 29 '18 at 1:24


















-1















Below is my nginx configuration.



    server_name  myserver.com;

location ~ /(in|sr)/(en|tm)/(.+.(css|js)) {
proxy_set_header Host http://mybucketabc.s3.amazonaws.com;

proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header Authorization '';
proxy_hide_header x-amz-id-2;
proxy_hide_header x-amz-request-id;
proxy_hide_header x-amz-meta-server-side-encryption;
proxy_hide_header x-amz-server-side-encryption;
proxy_hide_header Set-Cookie;
proxy_ignore_headers Set-Cookie;
proxy_intercept_errors on;
add_header Cache-Control max-age=31536000;

rewrite ^/(in|sr)/(en|tm)/(.*) /$1/$2/$3 break;
proxy_pass http://mybucketabc.s3.amazonaws.com;
}


When I try to access http://myserver.com/in/en/main.9bd9926d.js, I'm getting "400 Bad Request"



But directly accessing http://mybucketabc.s3.amazonaws.com/in/en/main.9bd9926d.js works fine.



I've similar proxy pass rules for html and svg files, both works fine but requests to .js files always throws "400 Bad Request".



Any help is really appreciated.










share|improve this question













closed as off-topic by Makyen, jww, Vega, Mike M., Pearly Spencer Nov 29 '18 at 11:29


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Questions about general computing hardware and software are off-topic for Stack Overflow unless they directly involve tools used primarily for programming. You may be able to get help on Super User." – Makyen, jww, Mike M., Pearly Spencer

If this question can be reworded to fit the rules in the help center, please edit the question.

















  • Have you tried making a simpler location with the bare minimum of directives and slowly adding back in directives? I do something similar with just proxy_pass, proxy_intercept_errors, and recursive_error_pages

    – Shawn C.
    Nov 28 '18 at 21:17











  • That attempt helped me to resolve the issue. It was happening due wrong Host. proxy_set_header Host mybucketabc.s3.amazonaws.com; "http://" got added in the host by mistake. Thanks a lot.

    – Sunil
    Nov 29 '18 at 1:24
















-1












-1








-1


0






Below is my nginx configuration.



    server_name  myserver.com;

location ~ /(in|sr)/(en|tm)/(.+.(css|js)) {
proxy_set_header Host http://mybucketabc.s3.amazonaws.com;

proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header Authorization '';
proxy_hide_header x-amz-id-2;
proxy_hide_header x-amz-request-id;
proxy_hide_header x-amz-meta-server-side-encryption;
proxy_hide_header x-amz-server-side-encryption;
proxy_hide_header Set-Cookie;
proxy_ignore_headers Set-Cookie;
proxy_intercept_errors on;
add_header Cache-Control max-age=31536000;

rewrite ^/(in|sr)/(en|tm)/(.*) /$1/$2/$3 break;
proxy_pass http://mybucketabc.s3.amazonaws.com;
}


When I try to access http://myserver.com/in/en/main.9bd9926d.js, I'm getting "400 Bad Request"



But directly accessing http://mybucketabc.s3.amazonaws.com/in/en/main.9bd9926d.js works fine.



I've similar proxy pass rules for html and svg files, both works fine but requests to .js files always throws "400 Bad Request".



Any help is really appreciated.










share|improve this question














Below is my nginx configuration.



    server_name  myserver.com;

location ~ /(in|sr)/(en|tm)/(.+.(css|js)) {
proxy_set_header Host http://mybucketabc.s3.amazonaws.com;

proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header Authorization '';
proxy_hide_header x-amz-id-2;
proxy_hide_header x-amz-request-id;
proxy_hide_header x-amz-meta-server-side-encryption;
proxy_hide_header x-amz-server-side-encryption;
proxy_hide_header Set-Cookie;
proxy_ignore_headers Set-Cookie;
proxy_intercept_errors on;
add_header Cache-Control max-age=31536000;

rewrite ^/(in|sr)/(en|tm)/(.*) /$1/$2/$3 break;
proxy_pass http://mybucketabc.s3.amazonaws.com;
}


When I try to access http://myserver.com/in/en/main.9bd9926d.js, I'm getting "400 Bad Request"



But directly accessing http://mybucketabc.s3.amazonaws.com/in/en/main.9bd9926d.js works fine.



I've similar proxy pass rules for html and svg files, both works fine but requests to .js files always throws "400 Bad Request".



Any help is really appreciated.







nginx amazon-s3 proxypass






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 28 '18 at 16:44









SunilSunil

112




112




closed as off-topic by Makyen, jww, Vega, Mike M., Pearly Spencer Nov 29 '18 at 11:29


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Questions about general computing hardware and software are off-topic for Stack Overflow unless they directly involve tools used primarily for programming. You may be able to get help on Super User." – Makyen, jww, Mike M., Pearly Spencer

If this question can be reworded to fit the rules in the help center, please edit the question.







closed as off-topic by Makyen, jww, Vega, Mike M., Pearly Spencer Nov 29 '18 at 11:29


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Questions about general computing hardware and software are off-topic for Stack Overflow unless they directly involve tools used primarily for programming. You may be able to get help on Super User." – Makyen, jww, Mike M., Pearly Spencer

If this question can be reworded to fit the rules in the help center, please edit the question.













  • Have you tried making a simpler location with the bare minimum of directives and slowly adding back in directives? I do something similar with just proxy_pass, proxy_intercept_errors, and recursive_error_pages

    – Shawn C.
    Nov 28 '18 at 21:17











  • That attempt helped me to resolve the issue. It was happening due wrong Host. proxy_set_header Host mybucketabc.s3.amazonaws.com; "http://" got added in the host by mistake. Thanks a lot.

    – Sunil
    Nov 29 '18 at 1:24





















  • Have you tried making a simpler location with the bare minimum of directives and slowly adding back in directives? I do something similar with just proxy_pass, proxy_intercept_errors, and recursive_error_pages

    – Shawn C.
    Nov 28 '18 at 21:17











  • That attempt helped me to resolve the issue. It was happening due wrong Host. proxy_set_header Host mybucketabc.s3.amazonaws.com; "http://" got added in the host by mistake. Thanks a lot.

    – Sunil
    Nov 29 '18 at 1:24



















Have you tried making a simpler location with the bare minimum of directives and slowly adding back in directives? I do something similar with just proxy_pass, proxy_intercept_errors, and recursive_error_pages

– Shawn C.
Nov 28 '18 at 21:17





Have you tried making a simpler location with the bare minimum of directives and slowly adding back in directives? I do something similar with just proxy_pass, proxy_intercept_errors, and recursive_error_pages

– Shawn C.
Nov 28 '18 at 21:17













That attempt helped me to resolve the issue. It was happening due wrong Host. proxy_set_header Host mybucketabc.s3.amazonaws.com; "http://" got added in the host by mistake. Thanks a lot.

– Sunil
Nov 29 '18 at 1:24







That attempt helped me to resolve the issue. It was happening due wrong Host. proxy_set_header Host mybucketabc.s3.amazonaws.com; "http://" got added in the host by mistake. Thanks a lot.

– Sunil
Nov 29 '18 at 1:24














1 Answer
1






active

oldest

votes


















1














This got resolved after correcting the Host.



Wrong Host
proxy_set_header Host http://mybucketabc.s3.amazonaws.com;



Correct Host (removed "http://")
proxy_set_header Host mybucketabc.s3.amazonaws.com;






share|improve this answer






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    This got resolved after correcting the Host.



    Wrong Host
    proxy_set_header Host http://mybucketabc.s3.amazonaws.com;



    Correct Host (removed "http://")
    proxy_set_header Host mybucketabc.s3.amazonaws.com;






    share|improve this answer




























      1














      This got resolved after correcting the Host.



      Wrong Host
      proxy_set_header Host http://mybucketabc.s3.amazonaws.com;



      Correct Host (removed "http://")
      proxy_set_header Host mybucketabc.s3.amazonaws.com;






      share|improve this answer


























        1












        1








        1







        This got resolved after correcting the Host.



        Wrong Host
        proxy_set_header Host http://mybucketabc.s3.amazonaws.com;



        Correct Host (removed "http://")
        proxy_set_header Host mybucketabc.s3.amazonaws.com;






        share|improve this answer













        This got resolved after correcting the Host.



        Wrong Host
        proxy_set_header Host http://mybucketabc.s3.amazonaws.com;



        Correct Host (removed "http://")
        proxy_set_header Host mybucketabc.s3.amazonaws.com;







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 29 '18 at 1:30









        SunilSunil

        112




        112

















            Popular posts from this blog

            Lallio

            Futebolista

            Jornalista