Score:0

Make nginx accept requests only from a specific server

et flag

I want to configure an nginx server to accept HTTP requests only from a specific server.

I am not sure if this should be accomplished through the listen directive, or by using allow/deny rules in location. Or another method that I am not aware of.

When trying to find documentation about listen, I haven't found an example that uses an actual external IP, only stuff like localhost or other interfaces.

Is what I want even possible with listen? Or is allow/deny the better way to do it?

Score:1
ws flag

You seem to be focussing on restricting access by IP address - and even static IP addresses aren't permanent. There are better ways to go about this but they are a little involved (shared secret, VPN, client certs).

Yes, you can use the allow/deny rules. These can be in the location block, the server block or even the http block.

liakoyras avatar
et flag
I am aware of the caveats, however the only way for this to be done right now is using the IP. Do you know if it could also be done with `listen`? (this was also part of my question)
ws flag
The IP address option on the Listen directive specifies which LOCAL ip address nginx should accept connections on - so unless you have some very esoteric networking going on (e.g. a VPN) then this doesn't help.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.