Nginx domain resolution 502 gateway

classic Classic list List threaded Threaded
2 messages Options
xrd
Reply | Threaded
Open this post in threaded view
|

Nginx domain resolution 502 gateway

xrd
I have developed a website for a customer, it's currently sitting on a
sub-domain on our server and is finished but i now need to carry out testing
for eCommerce payments and that means the site needs to move from our
sub-domain over to their live domain.

For this, i've created a cPanel account with that domain but because it's
live elsewhere, the best way for me to complete the migration before any DNS
records are changed on the 3rd party hosting is to be able to access the
site on my machine, i edited my local host files (windows) for that reason

Before NGINX was installed on the CentOS server, modifying the local host
file would work perfectly and i could access the site only on my machine to
finish up the migration, then when finished i'll ask the 3rd party host to
change NS to our us, meaning no downtime to their site and a nice
migration.

At the moment, even though the host file is changed and a local cmd ping
brings up our server, i get a 502 gateway error nginx in the browser,
checking nginx error logs i believe it's because nginx server is trying to
resolve the 3rd party real host IP address but my machine is set to resolve
the server ip version.

Does that make sense? All other sites on the server are working fine through
Apache + Nginx but i'm stuck with this problem.

I could simply ask the 3rd party hosting company to change the A record to
point to our server but it would mean the client would face some downtime
while i finished up the migration.

Any help is appreciated.

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,285702,285702#msg-285702

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: Nginx domain resolution 502 gateway

Francis Daly
On Wed, Sep 25, 2019 at 06:06:16AM -0400, medievil19 wrote:

Hi there,

> At the moment, even though the host file is changed and a local cmd ping
> brings up our server, i get a 502 gateway error nginx in the browser,
> checking nginx error logs i believe it's because nginx server is trying to
> resolve the 3rd party real host IP address but my machine is set to resolve
> the server ip version.

If your nginx config file uses hostnames in the form

  proxy_pass http://$variable;

then nginx needs to use a run-time resolver to find the IP address. That
will probably not use the local hosts file, even indirectly.

If your nginx config uses hostnames in the form

  proxy_pass http://www.example.com;

then nginx will use the system resolver at startup to find the IP address.
That will probably use the local hosts file.

I confess that from your mail, I am not sure what machines are involved
in your system, and how you want them to interact. So I can't say exactly
what should be changed, where.

But hopefully the above will help you work out what needs doing.

Good luck with it,

        f
--
Francis Daly        [hidden email]
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx