logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Reverse Proxy with SSL Help
Author
cydney2144



Joined: 01 May 2018
Posts: 1
Location: US, Memphis

PostPosted: Wed 02 May '18 19:57    Post subject: Reverse Proxy with SSL Help Reply with quote

So for the last two days I have been struggling with setting up a Apache2 Reverse Proxy. Involved in this are 3 servers, all VMs, all on the same network. The proxy server is accessible from its public IP and subdomain name. ( Well say its PROXY.MYDOMAIN.COM) and gave me the default 'Apache2 is working' page. The proxy server is the only server with a public face and ports 80 and 443 are forwarded to the proxy server. The proxy also has a SSL cert from letsencrypt by way of certbot and redirects 80 to 443.

The two servers that are internal are a Wordpress site and a Nextcloud server, both are completely separate VMs.

I have set the ports for Wordpress 80 = 8001, 443 = 8002 (SSL though it has no cert) and Nextcloud 80 = 8003, 443 = 8004 (It has a self signed cert.)

Wordpress was installed in /var/www/html/wordpress. I have set the /wordpress dir at the apache2 home dir so when you got to the servers IP 11.11.11.11:8001 there is no need to add ...8001/wordpress

Nextcloud was installed in /var/www/html/nextcloud. Nextcloud I have not set the apache2 home dir to the nextcloud dir so you have to go to 22.22.22.22:8003/nextcloud to reach the site.

##### wordpress vhost #####

Code:
<VirtualHost *:80>
    ServerName PROXY.MYDOMAIN.COM
    Redirect / https:// PROXY.MYDOMAIN.COM/
RewriteEngine on
RewriteCond %{SERVER_NAME} = PROXY.MYDOMAIN.COM
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>


##### end of line #####

##### wordpress ssl vhost #####

Code:
<IfModule mod_ssl.c>
<VirtualHost *:443>

  ProxyRequests Off
  ProxyPreserveHost On

  SSLEngine on

  ServerName PROXY.MYDOMAIN.COM
  ProxyPass / http://11.11.11.11:8001/
  ProxyPassReverse / http://11.11.11.11:8001/
  RequestHeader set X-Forwarded-Proto "https"


  SSLCertificateFile /etc/letsencrypt/live/PROXY.MYDOMAIN.COM/fullchain.pem
  SSLCertificateKeyFile /etc/letsencrypt/live/PROXY.MYDOMAIN.COM/privkey.pem

  Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>

##### end of line #####

So when I go to http://PROXY.MYDOMAIN.COM I am redirected to https://PROXY.MYDOMAIN.COM
and the wordpress site loads... kind'a. See the attachment.

One question I still am not sure about, is it possible to use the same subdomain http://PROXY.MYDOMAIN.COM with a reverse proxy so server the two sites? Like say the home ( http://PROXY.MYDOMAIN.COM ) is the wordpress site and the nextcloud is http://PROXY.MYDOMAIN.COM/nextcloud?

I have looked over various sites trying to figure out where I'm going wrong. I know someone will mention this so let me go ahead and answer. I have tried this with Nginx as well never could get it to work or even display anything. A lot of these 'its so easy guides' assume a little to much about the person that's using them. Admittedly I have more experience with Apache2 but I'm still not the most learned when it comes to this type of project.

Thanks in advanced for any help or advice.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7371
Location: Germany, Next to Hamburg

PostPosted: Mon 07 May '18 10:40    Post subject: Reply with quote

Yes you can use a different ProxyPass + ProxyPassReverse within Location

e.g.
Code:

<Location />
    ProxyPass http://11.11.11.11:8001/
    ProxyPassReverse http://11.11.11.11:8001/
    RequestHeader set X-Forwarded-Proto "https"
</Location>
<Location /nextcloud>
    ProxyPass http://OTHER-IP:PORT
    ProxyPassReverse http://OTHER-IP:PORT
    RequestHeader set X-Forwarded-Proto "https"
</Location>
Back to top


Reply to topic   Topic: Reverse Proxy with SSL Help View previous topic :: View next topic
Post new topic   Forum Index -> Apache