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: ProxyPass(Reverse) for a wix website [SOLVED]
Author
fermulator



Joined: 30 Oct 2019
Posts: 4
Location: Canada

PostPosted: Wed 30 Oct '19 16:06    Post subject: ProxyPass(Reverse) for a wix website [SOLVED] Reply with quote

Hey all,

I'm trying to save some $$ and not pay wix monthly to hook my website into a domain. Smile Apache ftw! Almost got it working, but having a wee bit closing the deal and making it work, hoping someone can spot my oopsie.

--
* WIX website: https://mysite.wixsite.com/foo-subsite
* MY PROXY: https://foo.diyplans.org
--

Apache configuration
Code:

$ cat 000-foo.conf
<IfModule mod_ssl.c>
<VirtualHost *:443>
   # The ServerName directive sets the request scheme, hostname and port that
   # the server uses to identify itself. This is used when creating
   # redirection URLs. In the context of virtual hosts, the ServerName
   # specifies what hostname must appear in the request's Host: header to
   # match this virtual host. For the default virtual host (this file) this
   # value is not decisive as it is used as a last resort host regardless.
   # However, you must set it for any further virtual host explicitly.
   ServerName foo.diyplans.org

   ErrorLog ${APACHE_LOG_DIR}/error_foo.log
   CustomLog ${APACHE_LOG_DIR}/access_foo.log combined

   SSLEngine on

   ProxyRequests Off
   ProxyPreserveHost Off

   SSLProxyEngine On
   #SSLProxyVerify none
   #SSLProxyCheckPeerCN off
   #SSLProxyCheckPeerName off
   #SSLProxyCheckPeerExpire off

   ProxyPass "/" https://mysite.wixsite.com:443/foo/
   ProxyPassReverse "/" https://mysite.wixsite.com:443/foo/
   #RequestHeader set Host "mysite.wixsite.com"

   SSLCertificateFile /etc/letsencrypt/live/foo.diyplans.org/fullchain.pem
   SSLCertificateKeyFile /etc/letsencrypt/live/foo.diyplans.org/privkey.pem
   Include /etc/letsencrypt/options-ssl-apache.conf


<Location />
   Order deny,allow
   Deny from all
   Allow from all
</Location>

</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
</IfModule>


This works to proxy through. HOWEVER the "sub-links" within wix still point to the WIX site itself (of course ...) but they don't work at all. Maybe they have some javascript preventing this from working?

Here's the current state of the site fwiw: https://ecobee-wired-sensors.diyplans.org/
(a little side project) :o[/code]


Last edited by fermulator on Thu 31 Oct '19 3:07; edited 2 times in total
Back to top
James Blond
Moderator


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

PostPosted: Wed 30 Oct '19 16:23    Post subject: Reply with quote

either you use mod_proxy_html[1] to rewrite internal link / src in the html or your need to have the foo part in your reverse path, too[2].


[1] https://httpd.apache.org/docs/2.4/mod/mod_proxy_html.html

[2]
e.g.

Code:

ProxyPass "/foo/" https://mysite.wixsite.com:443/foo/
   ProxyPassReverse "/foo/" https://mysite.wixsite.com:443/foo/


this would also require a redirect from / to /foo/
Back to top
fermulator



Joined: 30 Oct 2019
Posts: 4
Location: Canada

PostPosted: Thu 31 Oct '19 2:16    Post subject: Reply with quote

hm thanks! tried a few variances, each ended up with their own wonky behaviour; (seems like I need to learn more to get to this to work)


based off
* http://www.apachetutor.org/admin/reverseproxies
* https://httpd.apache.org/docs/2.4/mod/mod_proxy_html.html

I tried the `mod_proxy_html`, something like this I thought should do it,

Code:

SetOutputFilter INFLATE;proxy-html;DEFLATE
ProxyHTMLEnable On
ProxyHTMLURLMap "/foo/" "/"


however all the links still were pointing through to the "mysite.wix.com"

I read through the documentation more deeply and figured maybe I'd need other settings, also tried fiddling with
Code:

        #ProxyHTMLDocType "fpi" "XML"
        ProxyHTMLExtended On
        ProxyHTMLInterp On
        ProxyHTMLMeta On

, without success

I tried what you suggested to have both ProxyPass and ProxyPassReverse include the same suffix dir

Code:

        ProxyPass "/foo/" https://mysite.wixsite.com:443/foo/
        ProxyPassReverse "/foo/" https://mysite.wixsite.com:443/foo/

, but as expected (to me), the only affect that has is ONLY proxy'ing front-end requests to the "/foo" suffix to the proxy domain, doesn't seem to accomplish anything

If I inspect the link, it should be possible to HTMLmap this
Code:

/html/body/div/div[3]/div[4]/div/header/div[2]/div[2]/div/div/section/div[2]/div[2]/div/div[2]/div/div/div/div[1]/nav/ul/li[3]/a

<a role="button" tabindex="0" aria-haspopup="false" data-listposition="center" href="https://mysite.wixsite.com/foo/diy" target="_self" id="comp-jrp1k2ex2linkElement" class="style-jrp1k4herepeaterButtonlinkElement"><div class="style-jrp1k4herepeaterButton_gapper"><div style="text-align:right" id="comp-jrp1k2ex2bg" class="style-jrp1k4herepeaterButtonbg"><p style="text-align: right; line-height: 30px;" id="comp-jrp1k2ex2label" class="style-jrp1k4herepeaterButtonlabel">Do It Yourself (DIY)</p></div></div></a>
Back to top
fermulator



Joined: 30 Oct 2019
Posts: 4
Location: Canada

PostPosted: Thu 31 Oct '19 3:05    Post subject: Reply with quote

ah-ha! got it working, the trick in the URLMap I did not understand was that it is not GLOB match

Here's what the final version looks like (in case someone else would like to have it and do the same thing)

Code:

<IfModule mod_ssl.c>
<VirtualHost *:443>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        ServerName foo.diyplans.org

        ErrorLog ${APACHE_LOG_DIR}/error_foo.log
        CustomLog ${APACHE_LOG_DIR}/access_foo.log combined

        SSLEngine On
        SSLProxyEngine On

        ProxyRequests Off
        ProxyPreserveHost Off

        ProxyPass "/" https://mysite.wixsite.com:443/foo/
        ProxyPassReverse "/" https://mysite.wixsite.com:443/foo/

        SetOutputFilter INFLATE;proxy-html;DEFLATE
        ProxyHTMLEnable On
        ProxyHTMLExtended On
        ProxyHTMLInterp On
        ProxyHTMLURLMap "https://mysite.wixsite.com/foo/" "/"
        ProxyHTMLURLMap "https://mysite.wixsite.com/foo" "/"

        SSLCertificateFile /etc/letsencrypt/live/foo.diyplans.org/fullchain.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/foo.diyplans.org/privkey.pem
        Include /etc/letsencrypt/options-ssl-apache.conf


<Location />
        Order deny,allow
        Deny from all
        Allow from all
</Location>

</VirtualHost>
Back to top
fermulator



Joined: 30 Oct 2019
Posts: 4
Location: Canada

PostPosted: Thu 31 Oct '19 4:18    Post subject: Reply with quote

one minor backtrack, the contact us form doesn't work; not sure what is missing or will cause a form POST to not work in the Apache proxy setup
Back to top


Reply to topic   Topic: ProxyPass(Reverse) for a wix website [SOLVED] View previous topic :: View next topic
Post new topic   Forum Index -> Apache