<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Если коротко, то - <a href="https://serverfault.com/questions/598202/make-nginx-to-pass-hostname-of-the-upstream-when-reverseproxying" class="">https://serverfault.com/questions/598202/make-nginx-to-pass-hostname-of-the-upstream-when-reverseproxying</a><div class=""><br class=""></div><div class="">Второй ответ в треде.</div><div class="">Но сама схема, как по мне, выглядит костылем. Костылем и лечить.</div><div class=""><br class=""><div class="">
<div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;">-- </div><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;">With best regards,</div><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Dmitriy Lyalyuev</div><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><a href="mailto:dmitriy@lyalyuev.info" class="">dmitriy@lyalyuev.info</a></div><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div></div></div></div><br class="Apple-interchange-newline">
</div>
<div><br class=""><blockquote type="cite" class=""><div class="">On Jan 22, 2019, at 08:54, CoDDoC via nginx-ru <<a href="mailto:nginx-ru@nginx.org" class="">nginx-ru@nginx.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">
<div class="">Доброе время суток!<br class=""><br class="">Тестовый сервер: test.local. В нем тестовый кластер:<br class="">upstream cdn {<br class="">    server <IP_1>:<port_1>;<br class="">    server <IP_2>:<port_2>;<br class="">    ....<br class="">}<br class=""><br class="">или:<br class="">upstream cdn {<br class="">    server cdn001.test.local:<port_1>;<br class="">    server cdn002.test.local:<port_2>;<br class="">    ....<br class="">}<br class=""><br class="">Не принципиально, ибо "cdn001.test.local" резолвится в <IP_1> и т.д.<br class=""><br class="">Само собой, "proxy_http_version 1.1;" и из какого-то локейшена "proxy_pass <a href="http://cdn" class="">http://cdn</a>;"<br class="">Теперь смотрю, что приходит, например, на выбранный бэкенд.<br class="">Ожидаю там увидеть в заголовке Host значение <IP> или 'cdn###.test.local'.<br class="">Вижу: http header: "Host: cdn". Что не так?<br class=""><br class="">Входящий контроль проверяет правильность заголовка Host.<br class="">Все, что не соответствуют разрешенным, посылаются на 400. Можно, конечно, добавить фильтрацию по белому списку, что-то типа "такой-то IP должен прислать такой-то заголовок". Но (ИМХО) костыль.<br class=""><br class="">proxy_set_header 'Host' $upstream_addr; - бесполезно.<br class="">$upstream_addr получает значение ПОСЛЕ proxy_pass.<br class=""><br class="">Попутно вопрос о $upstream_addr.<br class="">Ее можно еще как-то использовать, кроме как в логах? Например, отправить в php, но без костылей?<br class=""><br class="">Спасибо.<br class="">--</div>
_______________________________________________<br class="">nginx-ru mailing list<br class=""><a href="mailto:nginx-ru@nginx.org" class="">nginx-ru@nginx.org</a><br class="">http://mailman.nginx.org/mailman/listinfo/nginx-ru</div></blockquote></div><br class=""></div></body></html>