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

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

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