Nginx Proxy pass to s3 for js files returns 400 Bad request [closed]
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
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.
add a comment |
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
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
add a comment |
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
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
nginx amazon-s3 proxypass
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
add a comment |
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
add a comment |
1 Answer
1
active
oldest
votes
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;
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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;
add a comment |
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;
add a comment |
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;
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;
answered Nov 29 '18 at 1:30
SunilSunil
112
112
add a comment |
add a comment |
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