Welcome! Log In Create A New Profile

Advanced

Why is nginx returning a 301 redirect in my reverse-proxy to a REST service?

March 25, 2016 08:02PM
I have a REST service with an endpoint ‘registrations' running in a Docker container and it maps port 5000 to port 5001 on the Docker host.

My /etc/nginx/conf.d/default.conf contains:

upstream registration-api {
server registration:5001 ;
}

server {

listen 80;
server_name "";

# Registration Service

location /registrations/ {
proxy_pass http://registration_api/;
}

}



I’m using Docker, so ‘registration-api’ is defined in the nginx container’s /etc/hosts file.

My Docker host is running at 192.168.99.100. I can run:

curl -v http://192.168.99.100:5001/registrations/

and I get the response I am expecting.

However, when I try to go through nginx reverse-proxy with the command:

curl -v http://192.168.99.100/registrations/

I get the following redirect:

* Trying 192.168.99.100...
* Connected to 192.168.99.100 (192.168.99.100) port 80 (#0)
> GET /registrations/ HTTP/1.1
> Host: 192.168.99.100
> User-Agent: curl/7.43.0
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
< Server: nginx/1.9.12
< Date: Fri, 25 Mar 2016 23:57:20 GMT
< Content-Type: text/html
< Transfer-Encoding: chunked
< Connection: keep-alive
< Location: http://localhost
< Expires: Fri, 25 Mar 2016 23:57:19 GMT
< Cache-Control: no-cache
<
<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx</center>
</body>
</html>
* Connection #0 to host 192.168.99.100 left intact

Any help would be appreciated,
Thanks,
Rowlad



_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Why is nginx returning a 301 redirect in my reverse-proxy to a REST service?

rowland@river2sea.org March 25, 2016 08:02PM

Re: Why is nginx returning a 301 redirect in my reverse-proxy to a REST service?

JoakimR March 25, 2016 11:09PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 180
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready