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

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

Последние авторы
1 |(% style="width:262px" %)Настройка заголовков перенаправления|(% style="width:1231px" %)(((
2 Заголовки используются, чтобы веб приложение могло сгенерировать корректные ссылки (относительно публичного endpoint), а не внутреннего адреса веб приложения.
3
4 (((
5 * (((
6 HTTP_X_FORWARDED_HOST
7 )))
8 )))
9
10 (((
11 * HTTP_X_FORWARDED_PROTO
12 * HTTP_X_FORWARDED_PORT
13 )))
14
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 )))
18 |(% style="width:262px" %)(((
19 --Отключения настройки
20 "Reverse rewrite host in response headers"--
21
22 См. пункт 1.
23 )))|(% style="width:1231px" %)(((
24 Возможны случаи, когда веб приложение будет формировать html страницы, содержащие некорректные ссылки. Например ссылающиеся не на адрес прокси, а на внутренний адрес приложения.
25 Потребуется, что прокси модифицировал исходящие страницы, переписывая содержимое на основе некоторых правил.
26
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
29 )))
30 |(% style="width:262px" %)Переписывание заголовков во входящих запросах для отключения сжатия в ответах сервера приложения.
31 (Например gzip)|(% style="width:1231px" %)(((
32 У IIS могут возникнуть проблем с изменением содержимого страницы, если ответ от сервера приложения возвращается в сжатом виде.
33
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
36
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
40 Замечание: заголовок с указанием сжатия для html контента, и для ответа от web api могут быть разными.
41 )))
42 |(% style="width:262px" %)(((
43 --Переписывание редирект ссылок в хедерах ответов от севера приложения.--
44
45 См. пункт 1.
46 )))|(% style="width:1231px" %)Modifying HTTP Response Headers
47 https://docs.microsoft.com/en-us/iis/extensions/url-rewrite-module/modifying-http-response-headers
48 |(% style="width:262px" %)(((
49 --Переписывание ссылок в html страницах, json ответах web api и другом контенте.--
50
51 См. пункт 1.
52 )))|(% style="width:1231px" %)(((
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
56 Замечание: паттерн сопоставления в html страницах и json документах могут различаться в следствии наличия/отсутствия/различии в экранировании символов.
57
58 {{code language="xml"}}
59 <outboundRules>
60 <preConditions>
61 <preCondition name="IsRedirection">
62 <add input="{RESPONSE_STATUS}" pattern="3\d\d" ></add>
63 </preCondition>
64 <preCondition name="ResponseIsHtml">
65 <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" ></add>
66 </preCondition>
67 <preCondition name="ResponseIsJson">
68 <add input="{RESPONSE_CONTENT_TYPE}" pattern="^application/json" ></add>
69 </preCondition>
70 </preConditions>
71 <rule name="Rewrite Location Header" preCondition="IsRedirection" stopProcessing="true">
72 <match serverVariable="RESPONSE_Location" pattern="http://ResponseUrl(.*)" ></match>
73 <action type="Rewrite" value="https://ProxyUrl{R:1}" ></action>
74 </rule>
75 <rule name="Rewrite static content" preCondition="ResponseIsHtml" stopProcessing="true">
76 <match filterByTags="None" pattern="http://ResponseUrl" ></match>
77 <action type="Rewrite" value="https://ProxyUrl" ></action>
78 </rule>
79 <rule name="Rewrite api content" preCondition="ResponseIsJson" stopProcessing="true">
80 <match filterByTags="None" pattern="http:\\/\\/ResponseUrl" ></match>
81 <action type="Rewrite" value="https://ProxyUrl" ></action>
82 </rule>
83 </outboundRules>
84 {{/code}}
85 )))
86 |(% style="width:262px" %) |(% style="width:1231px" %)
87 |(% style="width:262px" %) |(% style="width:1231px" %)