I am running my web app at abc.com
with apache as the web server.
I have some static pages hosted on SquareSpace... eg. abc.squarespace.com/landing
I want to configure apache to serve content from abc.squarespace.com
when it get's a request for abc.com/landing
I've done this in nginx by using proxy_pass with the backend as abc.squarespace.com
for location /landing
. But I'm not sure how to do this in Apache. No luck doing research on the web as well.
Thanks in advance.
Create a directory (also known as a folder) called static in the location of the script that runs the web.py server. Then place the static files you wish to serve in the static folder. For example, the URL http://localhost/static/logo.png will send the image ./static/logo. png to the client.
All the configuration files for Apache are located in /etc/httpd/conf and /etc/httpd/conf. d . The data for websites you'll run with Apache is located in /var/www by default, but you can change that if you want.
Put your HTML files in the C:\Program Files\Apache Group\Apache2\htdocs directory. Let's say you put file test. html there. You can then access it from the browser by typing http://localhost:8080/test.html in the URL area.
Message body cannot contain URLs with abc.com
, so I will be using example.com
and example.squarespace.com
.
I believe you are looking for frame forwarding. In order to implement it, use the following steps:
example.squarespace.com
allow frame forwarding from example.com
by setting the appropriate HTTP headers via web server configuration:X-Frame-Options: ALLOW-FROM https://example.com/
For detailed explanation refer to https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options
example.com
:# apachectl -M | grep proxy_http
proxy_http_module (shared)
.htaccess
file to serve content from http://example.squarespace.com/landing
<IfModule proxy_http_module>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
RewriteRule ^landing(.*) http://example.squarespace.com/landing [P]
</IfModule>
The syntax here is the same as for Apache mod_rewrite.
Not sure whether ask was for a redirection to abc.squarespace.com or proxy the call internally, here are the solutions for both
Redirection : browser will hit abc.com/landing and get a 301 redirect which changes url changes to abc.squarespace.com/landing
Add rule to httd.conf or included vhost file :
RewriteEngine on
RewriteRule "^/landing/(.+)" "http://abc.squarespace.com/landing/$1" [R,L]
Proxy : the abc.squarespace.com under abc.com > browser will not no that the page is served from any downstream domain.
Option 1: Use a rewrite rule with P(proxy) switch
RewriteEngine on
RewriteRule "^/landing/(.+)" "http://abc.squarespace.com/landing/$1" [P]
Option 2: Use a proxypass
ProxyPass "/landing" "http://abc.squarespace.com/landing"
ProxyPassReverse "/landing" "http://abc.squarespace.com/landing"
Additionally, timeout can be specified if needed and also a ProxyRemote can be configured if routing over any internet proxy is needed
Good References
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With