Исходный код вики Проблемы и сценарии
Редактировал(а) Alexandr Fokin 2026/09/02 16:03
Последние авторы
| author | version | line-number | content |
|---|---|---|---|
| 1 | |(% style="width:262px" %)Настройка заголовков перенаправления|(% style="width:1231px" %)((( | ||
| 2 | Заголовки используются, чтобы веб приложение могло генерировать корректные ссылки (относительно публичного endpoint, а не внутреннего адреса веб приложения). | ||
| 3 | |||
| 4 | * HTTP_X_FORWARDED_HOST | ||
| 5 | * HTTP_X_FORWARDED_PROTO | ||
| 6 | * HTTP_X_FORWARDED_PORT | ||
| 7 | |||
| 8 | ((( | ||
| 9 | |||
| 10 | ))) | ||
| 11 | |||
| 12 | How to Configure IIS as a Reverse Proxy | ||
| 13 | [[https:~~/~~/support.sonatype.com/hc/en-us/articles/115005086988-How-to-Configure-IIS-as-a-Reverse-Proxy-for-Sonatype-Products>>url:https://support.sonatype.com/hc/en-us/articles/115005086988-How-to-Configure-IIS-as-a-Reverse-Proxy-for-Sonatype-Products]] | ||
| 14 | ))) | ||
| 15 | |(% style="width:262px" %)((( | ||
| 16 | --Отключения настройки | ||
| 17 | "Reverse rewrite host in response headers"-- | ||
| 18 | |||
| 19 | См. пункт 1. | ||
| 20 | )))|(% style="width:1231px" %)((( | ||
| 21 | Возможны случаи, когда веб приложение будет формировать html страницы, содержащие некорректные ссылки. Например ссылающиеся не на адрес прокси, а на внутренний адрес приложения. | ||
| 22 | Потребуется, что прокси модифицировал исходящие страницы, переписывая содержимое на основе некоторых правил. | ||
| 23 | |||
| 24 | IIS reverse proxy with rewrites can't handle a redirect from the server we proxy to | ||
| 25 | https://stackoverflow.com/questions/4243959/iis-reverse-proxy-with-rewrites-cant-handle-a-redirect-from-the-server-we-proxy | ||
| 26 | ))) | ||
| 27 | |(% style="width:262px" %)Переписывание заголовков во входящих запросах для отключения сжатия в ответах сервера приложения. | ||
| 28 | (Например gzip)|(% style="width:1231px" %)((( | ||
| 29 | У IIS могут возникнуть проблем с изменением содержимого страницы, если ответ от сервера приложения возвращается в сжатом виде. | ||
| 30 | |||
| 31 | IIS as a reverse proxy - compression of rewritten response from backend server | ||
| 32 | https://stackoverflow.com/questions/15926203/iis-as-a-reverse-proxy-compression-of-rewritten-response-from-backend-server | ||
| 33 | |||
| 34 | The server variable is not allowed to be set. | ||
| 35 | http://www.sansys.net/2015/01/server-variable-is-not-allowed-to-be-set.html | ||
| 36 | |||
| 37 | Замечание: заголовок с указанием сжатия для html контента, и для ответа от web api могут быть разными. | ||
| 38 | ))) | ||
| 39 | |(% style="width:262px" %)((( | ||
| 40 | --Переписывание редирект ссылок в хедерах ответов от севера приложения.-- | ||
| 41 | |||
| 42 | См. пункт 1. | ||
| 43 | )))|(% style="width:1231px" %)Modifying HTTP Response Headers | ||
| 44 | https://docs.microsoft.com/en-us/iis/extensions/url-rewrite-module/modifying-http-response-headers | ||
| 45 | |(% style="width:262px" %)((( | ||
| 46 | --Переписывание ссылок в html страницах, json ответах web api и другом контенте.-- | ||
| 47 | |||
| 48 | См. пункт 1. | ||
| 49 | )))|(% style="width:1231px" %)((( | ||
| 50 | How to fix URL Rewriting for links inside CSS files with IIS7 | ||
| 51 | https://stackoverflow.com/questions/8653399/how-to-fix-url-rewriting-for-links-inside-css-files-with-iis7 | ||
| 52 | |||
| 53 | Замечание: паттерн сопоставления в html страницах и json документах могут различаться в следствии наличия/отсутствия/различии в экранировании символов. | ||
| 54 | |||
| 55 | {{code language="xml"}} | ||
| 56 | <outboundRules> | ||
| 57 | <preConditions> | ||
| 58 | <preCondition name="IsRedirection"> | ||
| 59 | <add input="{RESPONSE_STATUS}" pattern="3\d\d" ></add> | ||
| 60 | </preCondition> | ||
| 61 | <preCondition name="ResponseIsHtml"> | ||
| 62 | <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" ></add> | ||
| 63 | </preCondition> | ||
| 64 | <preCondition name="ResponseIsJson"> | ||
| 65 | <add input="{RESPONSE_CONTENT_TYPE}" pattern="^application/json" ></add> | ||
| 66 | </preCondition> | ||
| 67 | </preConditions> | ||
| 68 | <rule name="Rewrite Location Header" preCondition="IsRedirection" stopProcessing="true"> | ||
| 69 | <match serverVariable="RESPONSE_Location" pattern="http://ResponseUrl(.*)" ></match> | ||
| 70 | <action type="Rewrite" value="https://ProxyUrl{R:1}" ></action> | ||
| 71 | </rule> | ||
| 72 | <rule name="Rewrite static content" preCondition="ResponseIsHtml" stopProcessing="true"> | ||
| 73 | <match filterByTags="None" pattern="http://ResponseUrl" ></match> | ||
| 74 | <action type="Rewrite" value="https://ProxyUrl" ></action> | ||
| 75 | </rule> | ||
| 76 | <rule name="Rewrite api content" preCondition="ResponseIsJson" stopProcessing="true"> | ||
| 77 | <match filterByTags="None" pattern="http:\\/\\/ResponseUrl" ></match> | ||
| 78 | <action type="Rewrite" value="https://ProxyUrl" ></action> | ||
| 79 | </rule> | ||
| 80 | </outboundRules> | ||
| 81 | {{/code}} | ||
| 82 | ))) | ||
| 83 | |(% style="width:262px" %) |(% style="width:1231px" %) | ||
| 84 | |(% style="width:262px" %) |(% style="width:1231px" %) |