Advertisement
Guest User

Untitled

a guest
Sep 17th, 2023
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. applicationHost.xdt to specify that host header should be preserved and allow specific server variables (otherwise you get an exception). File is placed n the directory above wwwroot.
  2.  
  3. <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  4. <system.webServer>
  5. <proxy xdt:Transform="InsertIfMissing" enabled="true" preserveHostHeader="true" reverseRewriteHostInResponseHeaders="false"/>
  6. <rewrite xdt:Transform="InsertIfMissing">
  7. <allowedServerVariables xdt:Transform="InsertIfMissing">
  8. <add name="HTTP_X_ORIGINAL_HOST" xdt:Transform="InsertIfMissing" xdt:Locator="Match(name)"/>
  9. <add name="HTTP_X_UNPROXIED_URL" xdt:Transform="InsertIfMissing" xdt:Locator="Match(name)"/>
  10. <add name="HTTP_X_ORIGINAL_ACCEPT_ENCODING" xdt:Transform="InsertIfMissing" xdt:Locator="Match(name)"/>
  11. <add name="HTTP_ACCEPT_ENCODING" xdt:Transform="InsertIfMissing" xdt:Locator="Match(name)"/>
  12. <add name="HTTP_HOST" xdt:Transform="InsertIfMissing" xdt:Locator="Match(name)" />
  13. </allowedServerVariables>
  14. </rewrite>
  15. </system.webServer>
  16. </configuration>
  17.  
  18. web.config to specify how requests should be routed:
  19.  
  20. <system.webServer>
  21. <rewrite>
  22. <rules>
  23. <rule name="Blog Proxy" stopProcessing="false">
  24. <match url="^blog(?:$|/)(.*)" />
  25. <action type="Rewrite" url="https://blog.mywebsite.com/{R:1}" appendQueryString="true" logRewrittenUrl="false" />
  26. <serverVariables>
  27. <set name="HTTP_X_UNPROXIED_URL" value="https://blog.mywebsite.com/{R:1}" />
  28. <set name="HTTP_X_ORIGINAL_ACCEPT_ENCODING" value="{HTTP_ACCEPT_ENCODING}" />
  29. <set name="HTTP_X_ORIGINAL_HOST" value="{HTTP_HOST}" />
  30. <set name="HTTP_ACCEPT_ENCODING" value="" />
  31. </serverVariables>
  32. </rule>
  33. </rules>
  34. </rewrite>
  35. </system.webServer>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement