WordPress, load balancer and domain names

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

WordPress, load balancer and domain names

Dino Termini
Hi list,

I have a question for those who have dealt with MySQL replication. We
would like to create an environment with three servers: 1 authoring
server behind the firewall (server1.example.com), that only internal
users can access, and 2 public-facing servers behind a load balancer
(server2.example.com and server3.example.com, with load balancer
responding to server.example.com). Filesystems are synchronized via NFS,
and MySQL is set as master on the authoring and as slave on the two
public servers. In order to avoid issues (apparently WP caches oEmbeds
and other stuff when rendering pages), we set the slaves as read-only.

Now, content editors who access the authoring server, will type
server1.example.com, which is also the address configured in WordPress.
Unfortunately those URLs get copied over to the slaves. And that's were
problems start to arise. Have you ever dealt with a similar situation?
How did you solve the problem, or what would you recommend we change or
adapt to implement this architecture?

Thank you,
Dino
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: WordPress, load balancer and domain names

Filippo Pisano
Hi Dino,

You can set WP_HOME and WP_SITEURL accordingly to the server Url inside the
wp-config.php file of each server.
We have a similar enviroment and using this approach helped us solving the
same issue.

Unfortunately all links and images contained inside posts' content will
remain the same but you can always filter the content.
Il 23/lug/2014 21:17 "Dino Termini" <[hidden email]> ha scritto:

> Hi list,
>
> I have a question for those who have dealt with MySQL replication. We
> would like to create an environment with three servers: 1 authoring server
> behind the firewall (server1.example.com), that only internal users can
> access, and 2 public-facing servers behind a load balancer (
> server2.example.com and server3.example.com, with load balancer
> responding to server.example.com). Filesystems are synchronized via NFS,
> and MySQL is set as master on the authoring and as slave on the two public
> servers. In order to avoid issues (apparently WP caches oEmbeds and other
> stuff when rendering pages), we set the slaves as read-only.
>
> Now, content editors who access the authoring server, will type
> server1.example.com, which is also the address configured in WordPress.
> Unfortunately those URLs get copied over to the slaves. And that's were
> problems start to arise. Have you ever dealt with a similar situation? How
> did you solve the problem, or what would you recommend we change or adapt
> to implement this architecture?
>
> Thank you,
> Dino
> _______________________________________________
> wp-hackers mailing list
> [hidden email]
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: WordPress, load balancer and domain names

Dino Termini
Hi Filippo, I guess we can talk off-list about your setup. WP_HOME is
definitely a good start, but how do you filter the content? With a
plugin that detects on what server it's running?

Thank you for your quick reply!

On 7/23/14, 3:23 PM, Filippo Pisano wrote:

> Hi Dino,
>
> You can set WP_HOME and WP_SITEURL accordingly to the server Url inside the
> wp-config.php file of each server.
> We have a similar enviroment and using this approach helped us solving the
> same issue.
>
> Unfortunately all links and images contained inside posts' content will
> remain the same but you can always filter the content.
> Il 23/lug/2014 21:17 "Dino Termini" <[hidden email]> ha scritto:
>
>> Hi list,
>>
>> I have a question for those who have dealt with MySQL replication. We
>> would like to create an environment with three servers: 1 authoring server
>> behind the firewall (server1.example.com), that only internal users can
>> access, and 2 public-facing servers behind a load balancer (
>> server2.example.com and server3.example.com, with load balancer
>> responding to server.example.com). Filesystems are synchronized via NFS,
>> and MySQL is set as master on the authoring and as slave on the two public
>> servers. In order to avoid issues (apparently WP caches oEmbeds and other
>> stuff when rendering pages), we set the slaves as read-only.
>>
>> Now, content editors who access the authoring server, will type
>> server1.example.com, which is also the address configured in WordPress.
>> Unfortunately those URLs get copied over to the slaves. And that's were
>> problems start to arise. Have you ever dealt with a similar situation? How
>> did you solve the problem, or what would you recommend we change or adapt
>> to implement this architecture?
>>
>> Thank you,
>> Dino
>> _______________________________________________
>> wp-hackers mailing list
>> [hidden email]
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>
> _______________________________________________
> wp-hackers mailing list
> [hidden email]
> http://lists.automattic.com/mailman/listinfo/wp-hackers

_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: WordPress, load balancer and domain names

Mike Little-4
Anything you do in WordPress to resolve this issue is probably too slow.
I'm assuming a very busy site if you need to load balance two front end
servers.

I've done this before (or at least generating content on one url and
serving it on another) with apache proxying:

backend cms server: cms.example.com all content is written at that url.
front end server 1 server1.example.com uses mod_proxy and mod_substitute to
convert everything to public facing address.
front end server 2 server2.example.com uses mod_proxy and mod_substitute to
convert everything to public facing address.

e.g in the vhost setting
#make sure to translate all content types that may have urls in it
AddOutputFilterByType SUBSTITUTE text/html
AddOutputFilterByType SUBSTITUTE application/atom+xml
AddOutputFilterByType SUBSTITUTE application/xhtml+xml
AddOutputFilterByType SUBSTITUTE application/xml
AddOutputFilterByType SUBSTITUTE text/xml
AddOutputFilterByType SUBSTITUTE text/plain
AddOutputFilterByType SUBSTITUTE text/css
AddOutputFilterByType SUBSTITUTE text/javascript

Substitute s/cms.example.com/example.com/n

#proxy in and out
ProxyPass           / http://cms.example.com/
ProxyPassReverse    / http://cms.example.com/

# turn this off: we can't substitute in gzipped content
RequestHeader    unset  Accept-Encoding

This is very approximately what I remember, you will need to tweak it. I'm
sure nginx has an equivalent.


Mike
--
Mike Little
*WordPress Specialist*

Web: mikelittle.org
Skype: mike.little.zed1
Twitter: @mikelittlezed1
LinkedIn: linkedin.com/in/mikelittle

Founder and Director
*Zed1.com Limited*
http://zed1.com/
Registered in England & Wales, no. 6745562
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: WordPress, load balancer and domain names

Filippo Pisano
The solution provided by Mike is way more robust than replacing
strings/urls at the WordPress level.
Thank you for sharing it.



Filippo Pisano
cel: 3291821355 / skype: filippopisano


On Thu, Jul 24, 2014 at 12:00 AM, Mike Little <[hidden email]> wrote:

> Anything you do in WordPress to resolve this issue is probably too slow.
> I'm assuming a very busy site if you need to load balance two front end
> servers.
>
> I've done this before (or at least generating content on one url and
> serving it on another) with apache proxying:
>
> backend cms server: cms.example.com all content is written at that url.
> front end server 1 server1.example.com uses mod_proxy and mod_substitute
> to
> convert everything to public facing address.
> front end server 2 server2.example.com uses mod_proxy and mod_substitute
> to
> convert everything to public facing address.
>
> e.g in the vhost setting
> #make sure to translate all content types that may have urls in it
> AddOutputFilterByType SUBSTITUTE text/html
> AddOutputFilterByType SUBSTITUTE application/atom+xml
> AddOutputFilterByType SUBSTITUTE application/xhtml+xml
> AddOutputFilterByType SUBSTITUTE application/xml
> AddOutputFilterByType SUBSTITUTE text/xml
> AddOutputFilterByType SUBSTITUTE text/plain
> AddOutputFilterByType SUBSTITUTE text/css
> AddOutputFilterByType SUBSTITUTE text/javascript
>
> Substitute s/cms.example.com/example.com/n
>
> #proxy in and out
> ProxyPass           / http://cms.example.com/
> ProxyPassReverse    / http://cms.example.com/
>
> # turn this off: we can't substitute in gzipped content
> RequestHeader    unset  Accept-Encoding
>
> This is very approximately what I remember, you will need to tweak it. I'm
> sure nginx has an equivalent.
>
>
> Mike
> --
> Mike Little
> *WordPress Specialist*
>
> Web: mikelittle.org
> Skype: mike.little.zed1
> Twitter: @mikelittlezed1
> LinkedIn: linkedin.com/in/mikelittle
>
> Founder and Director
> *Zed1.com Limited*
> http://zed1.com/
> Registered in England & Wales, no. 6745562
> _______________________________________________
> wp-hackers mailing list
> [hidden email]
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers