Исходный код вики Проблемы и сценарии

Версия 1.19 от Alexandr Fokin на 2026/09/02 15:46

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