0

I have a website www.example.com on a hosting provider. We use that provider because it has a simple site builder my wife uses to maintain the site. Moving off of it isn't an option for this exercise.

I want to create an Apache proxy that can accept traffic for www.example.com that will simple pass all requests along to that hosted site, which is a vhost so hostname must be retained. I want to do this so I can use that proxy to add TLS (the hosting provider won't let us without charging triple - yes, they suck, but again, leaving isn't an option). And in order to create a Let's Encrypt cert for the site, I need the acme challenge process to find a specific file with specific content, but I cannot upload to the site itself (again, yes, they suck, no, we can't leave) So I did a RewriteRule that catches that request and redirects it to a file on my web server, but it displays as http://my-server.com/blah instead of http://www.example.com/path/to/file

What I've got so far:

<VirtualHost *:80>
    ServerName www.example.com
    ServerAlias exxample.com
    RequestHeader set Host "www.example.com"
    ProxyPreserveHost on
    ProxyPass / http://192.168.193.133 # IP of providers vhost
    ProxyPassreverse / http://192.168.193.133
    RewriteEngine On
    RewriteRule /path/to/file http://my-server.com/ssp-acme-challenge
</VirtualHost>

I need to get this working with HTTP only first so I can solve the challenge file issue. Then I want to fix to force all traffic to https and create a vhost for :443

1 Answer 1

0

If I understand what you specify correctly you just basically want to also proxy to the other site. So, just define the most specific path first for mod_proxy not interfere with the rest of paths that must be sent to 192.168.x.x site.

<VirtualHost *:80>
    ServerName www.example.com
    ServerAlias exxample.com
    RequestHeader set Host "www.example.com"
    ProxyPreserveHost on

    ProxyPass /path/to/file http://my-server.com/ssp-acme-challenge
    ProxyPassReverse /path/to/file http://my-server.com/ssp-acme-challenge

    ProxyPass / http://192.168.193.133/ # IP of providers vhost
    ProxyPassreverse / http://192.168.193.133/
</VirtualHost>

PS: Always try to match trailing slashes to avoid odd behaviours when proxying.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .