Created
December 19, 2025 13:24
-
-
Save meanother/24bab6f7740895693942d2c35b0a194b to your computer and use it in GitHub Desktop.
Nginx mirror
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| server { | |
| listen 8080; | |
| gzip on; | |
| gzip_vary on; | |
| gzip_proxied any; | |
| gzip_comp_level 6; | |
| gzip_buffers 16 8k; | |
| gzip_min_length 256; | |
| gzip_types | |
| text/plain | |
| text/javascript | |
| application/json; | |
| location / { | |
| include proxy_params; | |
| proxy_pass http://gateway; | |
| proxy_set_header Host $host; | |
| proxy_set_header X-Real-IP $remote_addr; | |
| proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
| mirror /mirror; | |
| mirror_request_body on; | |
| } | |
| location /mirror { | |
| internal; | |
| resolver 22.22.22.22 valid=360s; # внутренний DNS | |
| resolver_timeout 1s; | |
| set $target gateway.hello.net; | |
| # proxy_pass http://$target$request_uri; | |
| proxy_pass http://mirror_backend$request_uri; | |
| proxy_set_header Host $target; | |
| proxy_set_header X-Real-IP $remote_addr; | |
| proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
| proxy_set_header Connection ''; | |
| proxy_http_version 1.1; | |
| proxy_ignore_client_abort on; | |
| proxy_intercept_errors on; | |
| access_log off; | |
| error_log /dev/null crit; | |
| } | |
| } | |
| upstream gateway { | |
| server 127.0.0.1:8083; | |
| server 127.0.0.1:8084; | |
| server 127.0.0.1:8085; | |
| server 127.0.0.1:8086; | |
| server 127.0.0.1:8087; | |
| server 127.0.0.1:8088; | |
| server 127.0.0.1:8089; | |
| server 127.0.0.1:8090; | |
| keepalive 32; | |
| } | |
| upstream mirror_backend { | |
| server gateway.hello.net; | |
| keepalive 16; | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Есть высоконагруженная система скоринга (150 rps), входящий поток http запросов я принимаю в Nginx и проксирую через upstream gateway на 8 локальных инстансов, с которых запрос уходит в другие микросервисы.
Задача, нужно входящий поток зеркалировать на другой сервер в istio ingress, за которым стоят аналогичные микросервисы (8 gateways), просто на другом железе и под управлением k8.
Проблема следующая: конфиг рабочий, но при его активации, у потребителя (того, кто получает ответ не от mirror) появляются 10% таймаутов, против обычных 0.05%
При переключении на старый, упрощенный конфиг (без mirror) количество таймаутов возвращается к обычным значениям
Какие есть варианты?
Схема взаимодействия