I am trying to understand why my Apache 2.4 proxy is dropping the <!doctype html>
declaration, when connecting over an SSL connection (port 443), but not -- when connecting over any other port.
I have Apache proxy to an internal IIS server. When calling this page over http
I get the exact same code from Apache as when calling it directly from IIS. This is the page:
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Example document</title>
</head>
<body>
<p>Example paragraph</p>
</body>
</html>
However, if I connect via https
Apache drops the <!doctype html>
declaration and drops the <header>
tag, but not the content; and adds a mysterious empty <p> </p>
brackets. This is what I get in return:
<html><body><p>
</p>
<meta charset="UTF-8">
<title>Example document</title>
<p>Example paragraph</p>
</body></html>
I tried adding ProxyHTMLDocType "<!DOCTYPE html>"
and/or ProxyHTMLDocType html5
to the httpd-ssl.conf
file -- with no effect. (Naturally, I restarted Apache after making the changes.)
More Info
Apache access.log
1.2.3.4 - - [02/Apr/2017:11:58:00 -0700] "GET /test.html HTTP/1.1" 200 151
Requesting page directly from IIS by doing http://192.168.1.200:8089/file.html
returns as expected <!doctype html>...
. The same it true if requesting the page over http://example.com:8082/file.html
. But, strangely calling it like this: https://example.com/file.html
<!doctype html>
gets dropped. (See above...)
I am using Apache 2.4
IIS is listening :8089
Apache listening :80 :8082 and :443
Apache 2.4 httpd.conf
<VirtualHost *:8082>
ServerName www.example.net:8082
ServerName example.net:8082
<IfModule mod_proxy.c>
ProxyRequests Off
ProxyPass / http://192.168.1.200:8089/
ProxyPassReverse / http://192.168.1.200:8089/
</IfModule>
</VirtualHost>
Apache 2.4 httpd-ssl.conf file
<VirtualHost www.example.net:443>
ServerName www.example.net
<IfModule mod_proxy.c>
ProxyRequests Off
ProxyPass / http://192.168.1.200:8082/
ProxyPassReverse / http://192.168.1.200:8082/
...
</IfModule>
# --------------------------------------------------
# If I remove this section it works as expected, but
# the page returned includes links that are not rewritten:
# http://192.168.1.200:8082 gets not rewritten to
# https://www.example.net/
#
# this part rewrites the links but drops the DocType
#
<Proxy "http://192.168.1.200:8089">
ProxyHTMLEnable on
ProxyHTMLExtended on
ProxyHTMLMeta On
ProxyHTMLURLMap http://192.168.1.200:8082 https://www.example.net/
</Proxy>
# --------------------------------------------------
</VirtualHost>
More Info no. 2
I discovered that there is an error being recorded during in error_SSL.log if calling
[Mon Apr 03 18:51:32.821700 2017] [xml2enc:error] [pid 11008:tid 1736] [client 1.2.3.4:4961] AH01435: Charset ISO-8859-1 not supported. Consider aliasing it?
[Mon Apr 03 18:51:32.821700 2017] [xml2enc:warn] [pid 11008:tid 1736] [client 1.2.3.4:4961] AH01436: No usable charset information; using configuration default
I added in IIS 10 Manager default HTTP Response Header a new entry of the type name:Content-Type
value:charset=uft-8
just to be double sure that Apache is getting from IIS charset uft-8 and not charset ISO-8859-1. I also added ProxyHTMLCharsetOut UTF-8
to the proxy. So now it reads
<Proxy "http://192.168.1.200:8089">
ProxyHTMLEnable On
ProxyHTMLExtended On
ProxyHTMLMeta On
ProxyHTMLCharsetOut UTF-8
# find replace_with
ProxyHTMLURLMap http://192.168.1.105:8082 https://example.com/site1
ProxyHTMLURLMap http://192.168.1.105:8083 https://example.com/site2
ProxyHTMLURLMap http://192.168.1.105:8084 https://example.com/site3
</Proxy>