Searchprop Integration

Reverse Proxy

Mike Avery avatar
Written by Mike Avery
Updated over a week ago

Read this ^


Only to be completed once the customer has set up a subdomain of search.domain.com

Step 1 - Create new account

  • Navigate to the AI-GENTLE-SUMMIT server which is where all SearchProps are hosted currently: https://forge.laravel.com/servers/145587#/websites

  • Complete the New Site form at the top of the page to create the new account on the server:

    • input the Root Domain

    • leave Alisases blank

    • leave Project Type as General PHP / Laravel

    • delete the text in Web Directory

    • tick Use Website Isolation

    • click Add Site

  • You should now be taken into the new account you’ve just created

Step 2 - Add SSL

  • This is where you set the server for this account to secure (meaning it will sit on https:// rather than http://)

  • From within the new account

    • click SSL in the left hand navigation

    • click the LetsEncrypt box

    • click the green Obtain Certification button - you may need to wait a few moments

  • Once it’s done, you need to make an edit to complete the SSL setup

  • At the bottom of the page, click Files > Edit Nginx Configuration

  • Scroll down to line 30 and you should see the following 3 lines of code:

    location / {
    try_files $uri $uri/ /index.php?$query_string;
    }

  • Edit these 3 rows by adding a hash symbol at the start of each row, like this:

    #location / {
    #try_files $uri $uri/ /index.php?$query_string;
    #}

  • Directly above those 3 rows, paste the following new 3 lines of code, editing the domain name shown to be the relevant SearchProp domain for this customer (this should be the same as the preview link you sent the customer originally):

    location / {
    proxy_pass https://DOMAIN.search-prop.com/;
    }

    • Lines 30 - 36 should now look like this:

  • Click Save

All done!


Nginx Settings:

Find a property Search Prop redirect

Add under charset utf8:

## AGENTSINSIGHT

# Find-a-property

location /find-a-property/ {

proxy_pass http://[client].search-prop.com/;

}

# Fonts

location /fonts {

proxy_pass http://cwr.search-prop.com/fonts/;

}

#redirect old property-search (needs work to include property title if possible)

rewrite ^/old-directory http://www.domain.com/find-a-property permanent;

Create a domain alias in Forge

Create actual domain first and upload git repo

Create a domain alias - don't add a new repo, leave it blank.

Edit the nginx file and look for (currently on line 8):

root /home/forge/your-domain-alias;

Update this to root to your real domain

root /home/forge/actual-domain;

Htaccess Settings:

<IfModule mod_rewrite.c>

RewriteEngine on

# Redirect old pages to new location (For SEO reasons)

RewriteCond %{QUERY_STRING} ([0-9]+)$

RewriteRule ^find-a-property/property.php$ find-a-property/properties/%1? [R=301,L]

# If you have site specific fonts in your template link them in here

RewriteRule ^fonts/(.*)$ http://YOUR_SUB_DOMAIN.search-prop.com/fonts/$1 [L,P]

# Put search-prop onto the url '/find-a-property'

RewriteBase "/find-a-property"

RewriteRule "^find-a-property(.*)$" http://YOUR_SUB_DOMAIN.search-prop.com/$1 [P,L]

</IfModule>

*note: DO NOT set the URL above as https, but DO set it as httpS in the admin area of search prop

If two search props use this htaccess and put in the root

<IfModule mod_rewrite.c>

RewriteEngine on

# If you have site specific fonts in your template link them in here

RewriteRule ^fonts/(.*)$ http://wp-c.search-prop-dev.com/fonts/$1 [L,P]

# Put search-prop onto the url '/find-a-property'

RewriteBase "/commercial/find-a-property"

RewriteRule "^commercial/find-a-property(.*)$" http://wp-c.search-prop.com/$1 [P,L]

# Put search-prop onto the url '/find-a-property'

RewriteBase "/residential/find-a-property"

RewriteRule "^residential/find-a-property(.*)$" http://wp-r.search-prop.com/$1 [P,L]

</IfModule>

.htacess file

RewriteEngine on

# Set site specific fonts to pull from search-prop

RewriteRule ^fonts/(.*)$ https://co.search-prop.com/fonts/$1 [L,P]

# Proxy search-prop onto the url 'https://www.your-site.com/find-a-property

RewriteBase "/find-a-property"

RewriteRule "^find-a-property(.*)$" https://co.search-prop.com/$1 [P,L]

CORS Issues

Access-Control-Allow-Origin: https://co.search-prop.com


NOTES

  • For the redirect to work you cannot have a real folder in place that the re-write is trying to act on

    • "find-a-property folder was taking priority. Moving it out the way fixed the issue"

Microsoft Server (IIS) Settings:

Reverse Proxy with URL Rewrite v2 and Application Request Routing:


2. Create the rewrite rule.
Below is an example rule set for loading a search-prop onto the url: http://example.com/property-search

<rewrite>

<rules>

<rule name="Reverse Proxy Search Prop" stopProcessing="true">

<match url="^property-search/(.*)" />

<action type="Rewrite" url="http://fc.search-prop.com/properties/{R:1}" />

</rule>

</rules>

</rewrite>

3. Check routing is working

Once 1 & 2 are complete, you should be able to go to: http://example.com/property-search and they will see the property search.

4. Important! Link rewrites

You'll notice that clicking links on http://example.com/property-search will take you to the http://example.search-prop.com website.

To overcome this issue please let your contact at Kato know that you are ready to have the links set to the live domain. We will then toggle these so links keep the end-user on the http://example.com/property-search website.

Did this answer your question?