Reverse proxy redirection issue

Francis Daly francis at
Sat Sep 18 08:03:41 UTC 2021

On Fri, Sep 17, 2021 at 10:24:44PM -0300, Daniel Armando Rodriguez wrote:

Hi there,

> I am using nginx as a reverse proxy, I managed to configure SSL certificates
> using LetsEncrypt but nginx does the redirection to the wrong vhost.
> This is the configuration of one of the vhost, they are 3 identical ones
> pointing to the same virtual machine. I have a fourth one pointing to
> another virtual machine that works without problems.
> I have the domains, and
> pointing to the same internal IP. But any domain I enter in the browser the
> redirection is made to

I think you are reporting that if you do

    curl -i

you get a http 301 redirect from nginx to (which
is what you want); and if you do

    curl -i

you get a http 301 redirect from nginx to (which
is not what you want).

Is that correct?

If so...

> Also set a 4th as default_server, but behaviuor still remains.
> This is the vhost configuration
> ---
> # cat /etc/nginx/sites-enabled/
> server {
>     listen 80;
>     server_name;
>     server_tokens off;
>     # Don't show the nginx version number
>     include /etc/nginx/snippets/location-letsencrypt.conf;
> #    return 301$request_uri;
>     rewrite ^$request_uri? permanent;
> }

...can you show the "server" blocks that have "listen 80", to make sure
that they each have the expected "server_name" values and return/rewrite

The output of "nginx -T" should list the configuration that nginx actually
reads; that might be simpler to copy from than the files.

(There are other possible things to check too -- perhaps the problem is
not that "curl -i" gives the unwanted response,
but that "curl -i" gives the unwanted response. Or
perhaps the problem is that the requests are not getting to this nginx
at all. But, one step at a time, to identify where the problem is.)

Good luck with it,

Francis Daly        francis at

More information about the nginx mailing list