Nginx 获取当前ip

Sto*_*fke 1 nginx

我正在为一个站点编写一个通用配置脚本,并希望阻止除来自服务器本身的流量之外的所有到某个 url 的流量,因为我只想允许 SSH 隧道流量访问该站点的该部分。

location /admin {
    allow SERVERIP; 
    deny all;
}
Run Code Online (Sandbox Code Playgroud)

有 nginx 一个我可以使用的变量,所以我不必为我使用配置的每个服务器手动添加它。

Sc0*_*ian 7

$server_addr

an address of the server which accepted a request

Computing a value of this variable usually requires one system call. To avoid a system call, the listen directives must specify addresses and use the bind parameter.
Run Code Online (Sandbox Code Playgroud)

记录在这里。