小编had*_*des的帖子

nginx 中的函数

我对 nginx 很陌生,我有一个 nginx conf 脚本,它具有以下模板,example1example2具有相同的内容,我想将这些内容放入一个函数中(与编程中的方法相同的概念),并在其中传递参数以减少重复,可以这样做吗?我搜索了很长时间但没有看到做类似事情的例子。

server {
   server_name test.com

  location ^~ /example1/ {
      proxy_pass http://<some-ip>/example1/;
      proxy_set_header blah

  }

  location ^~ /example2/ {
      proxy_pass http://<some-ip>/example2/;
      proxy_set_header blah

  }

}
Run Code Online (Sandbox Code Playgroud)

nginx

7
推荐指数
1
解决办法
7392
查看次数

标签 统计

nginx ×1