Nginx and proxy_pass

Clash 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.
nginx proxy
add a comment |Â
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.
nginx proxy
Do you have a DNS resolver on127.0.0.1or1.1.1.1? You should not normally need to setresolverin 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 nginxresolversetting tells nginx to use a specific DNS resolver, which would require that a DNS service is listening at the specified location. I just noticed that1.1.1.1does 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 inproxy_pass. Have you verified that you can reachdomain2.comfrom thedomain1.comserver?
â 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
add a comment |Â
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.
nginx proxy
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.
nginx proxy
asked May 3 at 20:15
Duna
1
1
Do you have a DNS resolver on127.0.0.1or1.1.1.1? You should not normally need to setresolverin 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 nginxresolversetting tells nginx to use a specific DNS resolver, which would require that a DNS service is listening at the specified location. I just noticed that1.1.1.1does 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 inproxy_pass. Have you verified that you can reachdomain2.comfrom thedomain1.comserver?
â 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
add a comment |Â
Do you have a DNS resolver on127.0.0.1or1.1.1.1? You should not normally need to setresolverin 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 nginxresolversetting tells nginx to use a specific DNS resolver, which would require that a DNS service is listening at the specified location. I just noticed that1.1.1.1does 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 inproxy_pass. Have you verified that you can reachdomain2.comfrom thedomain1.comserver?
â 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
add a comment |Â
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.
add a comment |Â
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.
add a comment |Â
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.
add a comment |Â
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.
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.
answered May 4 at 8:07
Duna
1
1
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Do you have a DNS resolver on
127.0.0.1or1.1.1.1? You should not normally need to setresolverin 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
resolversetting tells nginx to use a specific DNS resolver, which would require that a DNS service is listening at the specified location. I just noticed that1.1.1.1does 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 inproxy_pass. Have you verified that you can reachdomain2.comfrom thedomain1.comserver?â 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