nginx reverse proxy proxy_pass weirdness
Francis Daly
francis at daoine.org
Wed Dec 18 16:28:16 UTC 2019
On Wed, Dec 18, 2019 at 10:33:44AM -0500, deeztek wrote:
Hi there,
> Sorry maybe I am confusing you. The config file that I posted, works fine.
> What I request actually responds. So, if I were to request www.domain.tld,
> the Apache server behind Nginx responds with the correct website for
> www.domain.tld. However, if I were to delete the config file for domain.tld
> from nginx and I tried to browse to that domain again, nginx would forward
> the request to another (seemingly random?) website on Apache behind it.
Ok, that makes sense to me now, thanks.
You are deleting a full server{} block; not just a single directive
within a server{} block.
http://nginx.org/en/docs/http/request_processing.html has the details
on what nginx is doing.
In short - a request comes in on an ip:port, with a Host header. If
nginx has a listener on that ip:port that handles that Host header,
the matching server{} is used to handle the request. If not, then the
default server for that ip:port handles the request.
You can configure which server is the default_server for this ip:port
on the "listen" line (http://nginx.org/r/listen).
> I would think, deleting a config from Nginx, it would simply stop forwarding
> requests for that cofig.
Historical reasons / backwards compatibility / overall convenience means
that that isn't what happens by default.
You can configure it to happen on your system, if you want it to, by
configuring your default server for this ip:port explicitly, and having
that server drop the connection, or return 404 or 410, or return useful
content advertising your hosting service.
That is part of the answer to "what response do you want to get instead?".
Cheers,
f
--
Francis Daly francis at daoine.org
More information about the nginx
mailing list