Apache reverse proxy with SSL gives ‘400 bad request’

apache-2.4odooproxypassreverse-proxyubuntu-16.04

I have an Odoo instance running on port 9069 in an Ubuntu server. Right now, apache is listening on port 8069 and is proxypass-ing this to 9069 (which works fine). The working URL is http://example.com:8069

Now, I need to make this work with SSL on the front end URL. (https://example.com:8069). However this is giving me 400 Bad request error when accessed in a browser. The exact error is:

Bad Request:
Your browser sent a request that this server could not understand.
Reason: You're speaking plain HTTP to an SSL-enabled server port.
Instead use the HTTPS scheme to access this URL, please.Apache/2.4.33 (Ubuntu) Server at example.com Port 8069

Also I noticed the URL gets changed to http version too.

The following is the virtualhost conf I've used for the domain.

<IfModule mod_ssl.c>
<VirtualHost *:8069>

  ServerName MySite
  ServerAlias example.com:8069

   SSLEngine on
   #SSLProxyEngine on
   SSLCertificateKeyFile /etc/apache2/sslfolder/mysite.key
   SSLCertificateFile    /etc/apache2/sslfolder/mysite.crt
   SSLCertificateChainFile /etc/apache2/sslfolder/mysite.txt

  ProxyPreserveHost On
  ProxyRequests Off

  ProxyPass /longpolling/ http://localhost:8072/
  ProxyPassReverse /longpolling/ http://localhost:8072/

  ProxyPass / http://localhost:9069/
  ProxyPassReverse / http://localhost:9069/

</VirtualHost>
</IfModule>

Already checked the apache error logs, but there's no useful information there.

Note: There is another virtualhost file for example.com, which is a pretty standard one with 80 and 443 ports configured. (It's just for the website, not odoo). I will post the virtualhost if you think it's relevant.

Best Answer

I actually fixed it using the below modifications.

ServerName MySite

is changed to

ServerName example.com:8069

And

ProxyPass / http://localhost:9069/
ProxyPassReverse / http://localhost:9069/

is changed to

ProxyPass / http://localhost:9069/
ProxyPassReverse / http://example.com:8069/
Related Topic