Question

I have an VB.NET MVC 4 application which functions correctly locally and on the server. But we are using an Apache reverse proxy to provide access to all of our applications, and when it is implemented for this, the form attributes generated via AjaxOptions are removed.

In this example:

<% Using (Ajax.BeginForm("getAdminSearchResults", "InitiationSearchResults", New AjaxOptions With {.HttpMethod = "post", .OnSuccess = "updatePlaceholder", .UpdateTargetId = "lstSearchResults"}, New With {.id = "frmSearch"}))%>

Without the reverse proxy, the HTML generated is:

<form action="/InitiationSearchResults/getAdminSearchResults?Length=23" data-ajax="true" data-ajax-method="post" data-ajax-mode="replace" data-ajax-success="updatePlaceholder" data-ajax-update="#lstSearchResults" id="frmSearch" method="post">

But with the reverse proxy:

<form action="/InitiationSearchResults/getAdminSearchResults?Length=23" id="frmSearch" method="post">

This of course causes the view to return data to the full page rather than the target div. Even if the form tag is hard-coded on the view, the reverse proxy ends up removing the data-ajax attributes. The only way I've been able to get the attributes to remain is by setting them via jQuery after the page is loaded. I've been scouring the Internet and have had zero success in figuring out why this is happening. Any assistance in this would be greatly appreciated. Perhaps a setting needs to be changed or added to the reverse proxy configuration?

LoadModule proxy_module         /usr/lib/apache2-prefork/mod_proxy.so
LoadModule proxy_http_module    /usr/lib/apache2-prefork/mod_proxy_http.so
LoadModule proxy_html_module    /usr/lib/apache2/mod_proxy_html.so
LoadModule rewrite_module       /usr/lib/apache2/mod_rewrite.so
LoadModule headers_module       /usr/lib/apache2-prefork/mod_headers.so
LoadModule substitute_module    /usr/lib/apache2/mod_substitute.so
LoadModule proxy_balancer_module        /usr/lib/apache2/mod_proxy_balancer.so

NameVirtualHost 10.125.186.140:443
NameVirtualHost 10.125.186.140:80

<VirtualHost 10.125.186.140:443>

ErrorDocument 404 /unknown.html

SSLEngine On

SSLCertificateFile /Cert/wildcard.crt
SSLCertificateKeyFile /Cert/wildcard.key
SSLCertificateChainFile /Cert/lawson_root.crt
SSLCertificateChainFile /Cert/entrust_l1e_chain_bundle.crt

ServerName qa-initiation.company.com
SSLProxyEngine on
ProxyReceiveBufferSize 4096
ProxyRequests Off

ProxyHTMLLinks  a               href
ProxyHTMLLinks  area            href
ProxyHTMLLinks  link            href
ProxyHTMLLinks  img             src longdesc usemap
ProxyHTMLLinks  object          classid codebase data usemap
ProxyHTMLLinks  q               cite
ProxyHTMLLinks  blockquote      cite
ProxyHTMLLinks  ins             cite
ProxyHTMLLinks  del             cite
ProxyHTMLLinks  form            action
ProxyHTMLLinks  input           src usemap
ProxyHTMLLinks  head            profile
ProxyHTMLLinks  base            href
ProxyHTMLLinks  script          src for

ProxyHTMLEvents onclick ondblclick onmousedown onmouseup \
        onmouseover onmousemove onmouseout onkeypress \
                onkeydown onkeyup onfocus onblur onload \
                onunload onsubmit onreset onselect onchange

ProxyHTMLDocType HTML
ProxyHTMLEnable On
ProxyHTMLExtended On

Header add Access-Control-Allow-Origin https://qa-oe.company.com

ProxyPassMatch (?i)^/(.*) https://onlineinit.companyqa.local/
ProxyPass / https://onlineinit.companyqa.local/
ProxyPassReverse / https://onlineinit.companyqa.local/
ProxyHTMLURLMap https://www.companyqa.local https://qa-oe.company.com l

</VirtualHost>
Était-ce utile?

La solution

Sorry this doesn't solve your problem but it might be useful.

Apache's mod_proxy_html rewrites your html and strips any attributes it doesn't recognize. For example,

<p style="color:white;" test="test"></p>

translates into

<p style="color:white;"></p>

after it passes through the reverse proxy. The reverse proxy also adds a DOCTYPE, and wraps the content in html and body tags, if not present.

I haven't found a way to avoid this except for turning off the html rewriting on that file/folder. I did this to turn it off for just the pages it was breaking, and used relative links in those pages:

<Location /path/to/badly/rewriten/stuff/>
SetOutputFilter none
</Location>

If there is a better way to do this, I'd like to know too!

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top