大网数据广告活动
服务器运维问答

Nginx mirroring without mirror module

· 52CE 我爱测

It has happened that someone that is not at my company anymore decided to manually compile nginx without knowing exactly what he was doing and put it into production. Now we cannot add modules and we are in a situation where we c…

问题原文

原帖链接 · smellyarmpits · CC BY-SA 4.0

It has happened that someone that is not at my company anymore decided to manually compile nginx without knowing exactly what he was doing and put it into production.

Now we cannot add modules and we are in a situation where we can't just turn off the nginx and start over with a fresh instance because it would disrupt customer's experience (because it is in production).

In order to get closer to the point (where we can substitute this nginx instance with a fresh and new one), we would like to implement mirroring. Again, we cannot install the mirror module right now. We have to do it in some other way.

I don't know anything about nginx, but I am the one that always wants to learn and like to go explore the web to discuss things with people.

Basically, we have a nginx that works as a reverse proxy. Requests that are sent to url/apis* are redirected to an internal API server. For testing purposes we need to mirror this traffic to another server. Someone at work came up with this solution, using post_action.

location ~* /apis*$ {
  proxy_pass http://api_server/$1;
  proxy_set_header Host      $host;
  proxy_set_header X-Real-IP $remote_addr;
  proxy_pass_request_headers      on;
  gzip "on";
  keepalive_timeout 10;
  post_action @mirror_test;
  }

  location @mirror_test{
    proxy_ignore_client_abort on;
    proxy_pass http://test_api_server/$1;
  }
}

Now, this solution does mirror the traffic correctly, but, we are not sure if the responses are ignored. Reading on the mirror module documentation, it says that the mirror subrequest responses using that module are ignored, and we would like to obtain the same behavior. Responses to clients should only come from the main server (api_server) and not from the mirrored one (test_api_server).

So, in this configuration, are the responses coming from the mirrored server ignored or not?

已采纳解答

原帖链接 · Tommiie · CC BY-SA 4.0

You can upgrade nginx without dropping a single client connection: https://www.digitalocean.com/community/tutorials/how-to-upgrade-nginx-in-place-without-dropping-client-connections

Update: The following text hits at your question in the comments:

The first step to gracefully updating our executable is to actually update your binary. Do this using whatever method is appropriate for your Nginx installation, whether through a package manager or a source installation.

Thus you can do a clean installation of the sources using whichever module you want to include or exclude and then use that binary for the upgrade process.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-09-14)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。