I encountered this same error and it can have absolutely nothing to do with your Tomcat configuration. It drove me crazy trying to find the error. I was serving multiple applications from six domains with only one of the domains producing the Proxy Error 502. The 'Invalid character' message is then found in Tomcat's log catalina.out:
Apr 18, 2018 10:31:06 AM org.apache.coyote.http11.AbstractHttp11Processor process
INFO: Error parsing HTTP request header
Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.
java.lang.IllegalArgumentException: Invalid character (CR or LF) found in method name
at org.apache.coyote.http11.InternalAprInputBuffer.parseRequestLine(InternalAprInputBuffer.java:177)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:992)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
at org.apache.tomcat.util.net.AprEndpoint$SocketWithOptionsProcessor.run(AprEndpoint.java:2454)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
In my case, I am sending requests to Tomcat applications from Apache httpd using a proxy. The proxy directives are used within httpd's virtual host, normally configured in /etc/httpd/conf.d/virtualhosts.conf. The proxy first redirects any unencrypted http requests received on port 80 to port 443.
<VirtualHost *:80>
ServerName www.domain1.com
ServerAlias domain1.com *.domain1.com
Redirect permanent / https://domain1.com/
</VirtualHost>
The redirected request is then handled as a normal incoming encrypted https request.
The incorrect configuration. DO NOT COPY THIS!
<VirtualHost *:443>
ServerName www.domain1.com
ServerAlias domain1.com *.domain1.com
ProxyRequests off
ProxyPreserveHost on
CustomLog "/etc/httpd/logs/domain1ssl.log" "%h %l %u %t \"%r\" %>s %b"
ErrorLog "/etc/httpd/logs/domain1ssl_error.log"
SSLEngine on
SSLProxyEngine on
SSLCertificateFile /etc/pki/tls/certs/domain1.com.crt
SSLCertificateKeyFile /etc/pki/tls/private/domain1.key
SSLCertificateChainFile /etc/pki/tls/certs/ca-bundle-domain1.crt
ProxyPass / https://domain1.com:8081/
ProxyPassReverse / https://domain1.com:8081/
</VirtualHost>
Note the two lines:
ProxyPass / https://domain1.com:8081/
ProxyPassReverse / https://domain1.com:8081/
The directives are telling Apache to send the request to the process listening on port 8081 as an encrypted request. This was typo on my part. The protocol should be http. Tomcat is not handling encryption, httpd is handling encryption. So Tomcat is receiving an encrypted request on a non-encrypted connector resulting in the 'Invalid character' error exceptionally well explained in Maciej Marczuk's (https://stackoverflow.com/users/1545775/maciej-marczuk) answer. Many thanks for cluing me in to finding my typo.
The proxy directives should be:
ProxyPass / http://domain1.com:8081/
ProxyPassReverse / http://domain1.com:8081/
Hope this helps someone.
Cheers.