LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 05-19-2024, 12:03 PM   #1
jnojr
Member
 
Registered: Sep 2007
Location: Chandler, AZ
Posts: 229

Rep: Reputation: 20
Apache config to proxy entire site with 1 exception


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).

What I've got so far:

Code:
<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
</VirtualHost>

Last edited by jnojr; 05-19-2024 at 03:39 PM.
 
Old 05-20-2024, 03:57 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,174
Blog Entries: 1

Rep: Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040
Hi,

If I understand well, you want to create a SSL reverse proxy in front of the actual website.
If that's the case then you'll have to setup a SSL server like this:
Code:
<VirtualHost *:443>
 ServerName www.example.com
# Put SSL related stuff, like cert, key etc...
  SSLEngine On
  SSLCertificateFile ...
  SSLCertificateKeyFile ...
  SSLProtocol
  ...
# Proxy directives:
   RequestHeader set Host "www.example.com"
   ProxyPreserveHost on
   ProxyPass / http://192.168.193.133/ # IP of providers vhost
   ProxyPassreverse / http://192.168.193.133/
   ...
</VirtualHost>
Mind that the trailing slash is important in the ProxyPass/ProxyPassreverse directives!

Regards
 
Old 05-20-2024, 09:03 AM   #3
jnojr
Member
 
Registered: Sep 2007
Location: Chandler, AZ
Posts: 229

Original Poster
Rep: Reputation: 20
Quote:
Originally Posted by bathory View Post
Hi,

If I understand well, you want to create a SSL reverse proxy in front of the actual website.
If that's the case then you'll have to setup a SSL server like this:
Code:
<VirtualHost *:443>
 ServerName www.example.com
# Put SSL related stuff, like cert, key etc...
  SSLEngine On
  SSLCertificateFile ...
  SSLCertificateKeyFile ...
  SSLProtocol
  ...
# Proxy directives:
   RequestHeader set Host "www.example.com"
   ProxyPreserveHost on
   ProxyPass / http://192.168.193.133/ # IP of providers vhost
   ProxyPassreverse / http://192.168.193.133/
   ...
</VirtualHost>
Mind that the trailing slash is important in the ProxyPass/ProxyPassreverse directives!

Regards
Didn't work, because I need to pass the hostname 'www.example.com' to the hoster... it's a vhost, visiting the IP gets you an error.
 
Old 05-20-2024, 12:02 PM   #4
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,174
Blog Entries: 1

Rep: Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040
Quote:
Didn't work, because I need to pass the hostname 'www.example.com' to the hoster... it's a vhost, visiting the IP gets you an error.
What is the error you get?
Maybe you should change your dns so the IP resolves to the SSL host and then use a non-SSL vhost in the backend webserver with the same hostname...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
letsencrypt exception on apache reverse proxy along with ip restrictions vincix Linux - Server 9 07-11-2019 03:16 PM
Apache site redirects using what rule? foo.site.com -> www.site.com/foo LaughingBoy Linux - Server 2 04-16-2009 09:51 PM
Apache Reverse Proxy, an entire site? colincraig127 Linux - Software 0 03-20-2008 04:25 PM
help createing exception class from base STL exception qwijibow Programming 4 04-20-2005 05:23 AM
Runtime Exception vs. Exception mikeshn Programming 1 09-22-2002 05:33 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 12:28 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration