Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache Reverse Proxy https to http

I've done a fair amount of browsing on here and the Internet but I can't configure my apache to reverse proxy https to http. I feel like I'm close however. All the examples I've followed seem to work for everyone except me and my setup is very simple.

<VirtualHost *:443>
ServerName myserver
SSLEngine On
SSLCertificateFile /path/to/file
SSLCertificateKeyFile /path/to/file
SSLCertificateChainFile /path/to/file
ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
    AddDefaultCharset Off
    Order deny,allow
    Allow from all
</Proxy>
ProxyPass / http://myserver:8081/
ProxyPassReverse / http://myserver:8081/

ErrorLog logs/myserver-error_log
CustomLog logs/myserver-access_log common
</VirtualHost>

So when I go to https://myserver/ I expect it to redirect to that port which is running Nexus.

Before I did SSL this was actually working for a VirtualHost *:80. I could go to http://myserver/ and end up at Nexus. Not sure why https is not working.

What's actually happening is https://myserver/ goes to https://myserver and displays a test index.html I have setup in the DocumentRoot.

like image 542
Justin Avatar asked Feb 20 '17 20:02

Justin


People also ask

Can Apache do reverse proxy?

In addition to being a "basic" web server, and providing static and dynamic content to end-users, Apache httpd (as well as most other web servers) can also act as a reverse proxy server, also-known-as a "gateway" server.

What is Proxyrequests?

Proxy servers work by facilitating web requests and responses between a user and web server. Typically, a user accesses a website by sending a direct request to its web server from a web browser via their IP address. The web server then sends a response containing the website data directly back to the user.

What is Proxy_module?

mod_proxy and related modules implement a proxy/gateway for Apache HTTP Server, supporting a number of popular protocols as well as several different load balancing algorithms. Third-party modules can add support for additional protocols and load balancing algorithms.


1 Answers

Turns out something funky was going on in with 443 port.

httpd was listening on that port, a nmap command from another machine showed 443 open but for some reason, however the VM of RHEL 7 was setup, it wasn't working.

So I switched ports and below is the configuration that eventually got my reverse proxy to https into apache and http to my Nexus repo.

Nexus returns a webpage with http links that break getting the content for that page but I only need the SSL for a docker daemon which won't be asking for webpages.

Listen 8082
<VirtualHost *:8082>
ServerName myserver
SSLEngine On
SSLCertificateFile /path/to/file
SSLCertificateKeyFile /path/to/file
SSLCertificateChainFile /path/to/file
ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
AddDefaultCharset Off
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://myserver:8081/
ProxyPassReverse / http://myserver:8081/

ErrorLog logs/myserver-error_log
CustomLog logs/myserver-access_log common
</VirtualHost>
like image 185
Justin Avatar answered Oct 23 '22 03:10

Justin