Community Aliases
Aliases to your community can be helpful if there is a need to load the community in multiple places, or if the community needs to be loaded in a “subfolder” on the domain instead of a subdomain. (IE: http://www.example.com/community)
Examples
The aliases can be setup with any reverse proxy by passing the headers “X-One-Node-Alias” and “Host”. Host refers to domain of the community, for example: community.example.com. X-One-Node-Alias is a combination to replace in the page’s DOM. For instance, if the reverse proxy lives on example.com/community, pass in community=example.com to replace all urls to community.example.com with example.com/community.
Curl
1 |
curl -L -H "Host: community.example.com" -H "X-One-Node-Alias: community=example.com" -v http://209.217.19.37/go/forum/viewboard |
Varnish
The following is an example implementation with Varnish. Depending on the needs of your project, your implementation may differ.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
acl allowed { "localhost"; "209.217.0.0"/16; } backend default { #.host = "209.217.36.198"; # Stage #.host = "209.217.19.55"; # Preproduction .host = "209.217.19.37"; # Production .port = "80"; } sub vcl_recv { if(!client.ip ~ allowed) { error 405 "Not Authorized."; } if (req.http.host ~ "^(www\.)?([a-zA-Z0-9]*\.)?example\.com" && req.url ~ "^/community/") { set req.http.host = "community.example.com"; set req.http.X-ONE-NODE-ALIAS = "community=example.com"; set req.url = regsub(req.url, "^/community/", "/"); set req.http.cookie_domain = ".example.com"; if (req.http.cookie) { set req.http.Cookie = req.http.Cookie "; CookieDomain=" req.http.cookie_domain; if (req.http.cookie ~ "^ *$") { remove req.http.cookie; } } } } sub vcl_fetch { if (obj.status != 200 && obj.status != 302) { restart; } if (obj.status == 302) { if (req.http.proxy_origin_host ~ "^(www\.)?([a-zA-Z0-9]*\.)?example\.com" && req.url~ "^/community/") { set obj.http.Location = regsub(obj.http.Location, "community\.example\.com", req.http.proxy_origin_host); } } } |
Headers
The ONEsite system relys on serveral headers from the being passed into the request. The reverse proxy system implemented should pass through the following headers without modification: X-Requested-With, User-Agent, Cookie, and Referer.
Host
The “Host” parameter should be the community’s domain in our database. For example: “community.example.com”. This string can be hardcoded into the application.
X-ONE-Node-Alias
The X-One-Node-Alias is a combination of the url where the reverse proxy lives seperated by an equal sign. An example value, where the reverse proxy is at “example.com/community” is “community=example.com”.
X-One-Cookie-Domain
X-One-Cookie-Domain refers to the domain where the cookies should be set. For a reverse proxy living on “example.com/community” pass in “.example.com”. In most instances, this variable can be hard coded.
X-Forwarded-For
X-Forwarded-For refers to the user’s IP address. This allows the system to capture the user’s actual IP address instead of your server’s IP Address. In PHP, this equates to the value “$_SERVER[‘REMOTE_ADDR’]”.