WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Can ADMIN be moved to a non-public server? Must DNS name of admin match blog? (15 posts)

  1. eric-o
    Member
    Posted 1 year ago #

    Hello,

    I'm running a large blog that is increasingly finding that it is outgrowing a single server. At present, load on the main server is cached with a varnish front end, but when users hit a large breadth of pages, the server is reaching capacity, causing editors using the admin panel to suffer.

    I am working toward splitting our wordpress install into a load-balancing scenario, and making preparations so that these systems can have a read only environment with some sort of mechanism for synching the files (probably lsyncd).

    So my big question is it possible to move the wordpress admin functions to a separate server, so as to guarantee Quality of Service for the writers of the blog, no matter what the traffic load is to the public site? As I am sure everyone here is aware, cloning the site to a separate server but sharing a database doesn't work, because the new "admin site" finds the rewrite rules in the database and wordpress redirects the user login to the public site.

    This has a couple of sub questions, I suppose:

    1. Is there any quick way around the built in redirect? Sometimes one just desperately wants this maintenance reasons. I'd be great to just put in a few lines of code in wp-admin.php, perhaps by accessing the admin panel on a separate port or URL and thereby have all traffic for the admin panel go to the admin server.

    2. Is this something that multi-site plus domain mapping can make work? I started to look into setting up a system where site A would be publicblog.com and site b would admin.publicblog.com, but it seems that the nature of subdomaining on the WP network function is really that of having multiple vhosts/domains on the same physical machine with one login. I want the opposite: I want to have a separate site B, on a separate server than A, with SSL etc. that updates the posts on Site A.

    Those are my core questions. Ancilliary to these might be:

    1 Is it hard coded into wordpress such that the site URL and the admin URL must be the same?

    2. Is there a "recommended" way to make wordpress work in a load-balancing environment. I see people creating a read-only file system and forcing media files to upload to Amazon S3. But what about plugins and themes? Do people sync those files (behind the back of wordpress) using the file system or is there a way to do this using the multisite functions?

    Thanks for any suggestions!

  2. esmi
    Forum Moderator
    Posted 1 year ago #

  3. eric-o
    Member
    Posted 1 year ago #

    Dear Esmi,

    Thanks for your suggestion.

    I am not using hyperdb right now, but probably will when switching to a load-balancing situation where I need to have multiple databases (largely for geographic diversity of data centers).

    But I guess I'm missing how adding multiple database servers (which is hyperdb's main function) would help with the problem of moving the admin functions to separate web server. I can see that hypderdb would allow one to make one DB a master for all writes, while all other DBs would be read only--and that is useful--but what I'm trying to do is duplicate (and separate out the functions) of the servers running apache. Or is there a function of hyperdb that I'm not seeing?

    best,
    Eric

  4. esmi
    Forum Moderator
    Posted 1 year ago #

    If you're having performance issues, the single biggest factor is going to be the number of database queries running at any one time. Load balancing databases should sort that out for you.

  5. eric-o
    Member
    Posted 1 year ago #

    Dear Esmi,

    I feel like I'm not communicating my question clearly, and I apologize. I thank you sincerely for the help.

    The performance issues I speak of are NOT database related, nor are they about the sheer number of hits per page. I'm trying to run a separate web site for the panel admin, rather than spread the panel admin work across a cluster of public servers.

    The reason I say it's not database related is because I've done extensive profiling on the site (both front end and back end), and we have everything in front of a reverse-proxy varnish cache and have the databases heavily cached.

    The issues that I'm concerned about here are web server (PHP related), occurring whenever there is a cache miss and we must serve up dynamic pages. That costs CPU on the apache box, and slows down the use of the panel, even though most public users never see this slowdown because they are largely seeing cached pages.

    It is for the sake of preserving Quality of Service for the writers and administrators of the site when the CPU for apache is busy running processes that I would like to move the admin panel functions to a different dns name.

    The boss is willing to pay to have a *guarantee* that the administrative panel always is available and instantaneous. It is for this reason that I'd like the box providing the panel service to be on a separate instance of apache, with a separate IP address and DNS name. Also this would allow the site editing, panel administration, or upgrades to apache to be done while varnish served out old pages.

    So has anyone successfully moved that administrative functions to a separate server?

    Maybe there's another practical way to ask the same question: has someone up a website at https://secure.blog.com that administers http://www.blog.com? And if so, were they successful in putting https://secure.blog.com on a separate physical server or virtual instance? Or is that simply *impossible* in the wordpress world? It seems like it would offer all sorts of good things, such as the ability to put one's admin site on a VPN.

    Thanks again,

    Eric

  6. esmi
    Forum Moderator
    Posted 1 year ago #

    To the best of my knowledge, you cannot split off the admin area on a single standalone site - let alone on a multisite setup.

  7. eric-o
    Member
    Posted 1 year ago #

    Do you think this is an "advanced" topic? Or does it belong somewhere else? I wasn't sure which forum to post it in.

    I'm happy to post it to another forum or write it up as a feature request. It seems like a pretty straightforward thing that would be very useful. Just being able to get into the panel when the outbound server is under heavy load has got to be an issue.

    I do understand it's a little bit like trying to move /wp-admin out of the path…but I'm willing to learn a fair amount about WP internals to make it work. At the very least I need to show I've tried.

    thanks,
    Eric

  8. Pothi
    Member
    Posted 1 year ago #

    Unfortunately, WordPress doesn't have the feature you mentioned, yet. Fortunately, it's an open source product, as you may already know, where anyone can add new features. If you can do it, with the help of others, I'm sure the entire community will benefit. Because the issue you mentioned is not uncommon on blogs with multiple writers.

    Those who have had the similar issue (almost unresponsive backend), have probably solved it with a combination of different tools, such as hyperdb or varnish. BTW, have you ever made use of grace mode in varnish? Have you considered moving backend traffic via SSL, and let it be handled by an alternative web server, such as Nginx? Have you considered php-fpm with APC? Have you considered WP Object Cache?

    I hope that helps.

  9. eric-o
    Member
    Posted 1 year ago #

    Dear Pothi,

    Thanks for your thoughts. To answer your questions: I am already using varnish. I will use hyperdb when it becomes necessary, but right now one database works just fine if set up with an memcached object cache. I do use php-fpm and xcache (instead of APC), although with Apache. Grace mode in varnish is indeed an awesome thing. I know a fair amount about server systems, but less about the design decisions that have gone into WordPress. I don't believe in fighting against something that is just inimical to the design. So that is why i am asking philosophically as well as for practical advice.

    I am a little intrigued in that regard by why you ask about "backend traffic via SSL". Do you mean the mysql traffic? That is already done. I think you mean, however, putting the operations of the SSL website (i.e. port 443, and the admin panel) on a separate web server? In fact, that is what I am asking….can one put the wp-admin area on a separate server, or must one distribute the wp-admin file calls equally across all servers serving that website?

    I have of course considered making varnish function as a loadbalancer/router/reverse proxy to push all the ssh traffic to a particular host. But the question was really one of considering whether there would be a way to get to that server consistently, via a dns name, even if that varnish server were down. Because of the way that wordpress handles rewrites, it would seem like every attempt to contact https://secure.blog.com is going to get rerouted to http://www.blog.com by the rewrite rules (not just the ones in .htaccess, but the ones in the wordpress rewrite framework). My question is whether there is a way of preventing that rewrite from happening---i.e. of allowing wordpress to modify a database which serves out http://www.blog.com while being accessed through https://secure.blog.com.

    So I'm not only trying to *consider* that, I'm actually trying to do it! But is this something someone else has done?

    Thanks again!
    Eric

  10. Pothi
    Member
    Posted 1 year ago #

    By 'backend', I meant sitename.com/(*/)?wp-admin and sitename.com/(*/)?wp-config.php . AFAIK, these can be modified, like how you'd like to have them in a sub-domain, at the application level. I'm not a coder or developer. So, I wish I am wrong here.

    I know your server already uses Varnish. That's why I mentioned grace mode that makes sure only one requests goes to the backend to fetch the updated content while other requests (to the same content) are served a slightly older version. This consideribly reduces the load when an object expires, and when there are multiple concurrent requests to the same object.

    For now, Varnish and SSL doesn't go together (ref: Why no SSL?), at least in the way we wish them. I do use SSL on my site with Varnish, but in my case, I run Nginx for SSL termination and Varnish runs in its default port only for caching, just like how varnish-cache.org works.

    What you wish to do is a unique thing that I haven't done or anyone else (that I know) has done. So, I only put my thoughts across to you. Implementing them may not be practical.

    can one put the wp-admin area on a separate server

    No, we can't.

    A little more on 'backend traffic to SSL': Since, your site runs on Varnish, I assume the entire site listens only to non-ssl traffic. So, when we put Nginx in place just to listen to SSL traffic, we basically take away some load from Apache/Varnish layer. Of course, we still hit the same PHP/MySQL layer, if we use only one server. With multiple servers (and with the use of hyperdb), we can still separate the front end traffic and the backend traffic.

    The front end traffic will still need wp-admin, to generate pages. However, the front end traffic will never affect the backend traffic, because both runs on separate servers.

    I hope that clarifies.

  11. eric-o
    Member
    Posted 1 year ago #

    Pothi,

    Thanks for your thoughts. Sigh, yes, part of the reason I am asking the question is because I would like to avoid putting another layer in front of everything. But basically what you are suggesting is to put nginx in front of varnish in order to accept and proxy the incoming SSL connections aimed at the underlying box. Do you have experience running nginx as a load balancer/proxy in front of varnish? And can it be done profitably on the same box? That's a lot of layers, and starts to make me wonder if one just doesn't get rid of varnish at that point, and use nginx in front of apache. I'd lose grace mode though, which is not desirable.

    right now I have

    user--> [varnish / apache app server /https ] ---> mysql server
    [ square brackets = all on the same box]

    I can't tell if you are recommending
    user--->[ nginx / varnish] ---> apache app servers [1-x] ---> mysql servers
    or
    user---> [nginx] --->[varnish] --->apache app servers [1-x] ---> mysql servers
    https user [nginx] ---> apache app servers [1-x] ---> mysql servers

    As far as I know, one would not be required to use the second one of these, but I don't know.

    my idea was to not have to have apache server x have a public ip address that one could just https directly into, perhaps with a php directive that forced an https connection to override the wp_home / wp_siteurl settings in the mysql databases.

    But it sounds like no one has ever tried that…and that's probably because there's some reason it won't work.

    Just to clarify, when you say use nginx here to separate out ssl from non-ssl traffic, you are just using nginx as a proxy server, right? Does wordpress have the ability to purge its cache in that situation? Or do you turn of caching in nginx and essentially use it instead of, say, haproxy?

    So any thoughts about putting nginx and varnish on the same box? Or does nginx just end up caching varnish's cache to disk and slow everything down?

    best,
    Eric

  12. Pothi
    Member
    Posted 1 year ago #

    Sorry about the confusion. I wasn't clear with what I said.

    Sigh, yes, part of the reason I am asking the question is because I would like to avoid putting another layer in front of everything. But basically what you are suggesting is to put nginx in front of varnish in order to accept and proxy the incoming SSL connections aimed at the underlying box.

    My thought was to let Nginx listen only on 443, and let Varnish listen on port 80 (this is already in place, I guess). There is no additional layer here.

    All backend traffic would use Nginx=>php-fpm=>mysql_master (this is one server).

    All front end traffic would use Varnish=>Apache=>php-fpm=>mysql_slave (this is another server)

    Do you have experience running nginx as a load balancer/proxy in front of varnish? And can it be done profitably on the same box?

    For both questions, short answer is no. Technically, it is still possible to do what I suggested in a single box, provided we are ready to mess-up at some point in the future, by running two PHP versions in different sockets / ports. :)

    Just to clarify, when you say use nginx here to separate out ssl from non-ssl traffic, you are just using nginx as a proxy server, right? Does wordpress have the ability to purge its cache in that situation? Or do you turn of caching in nginx and essentially use it instead of, say, haproxy?

    In the above setup, Nginx works as a simple web server. Using Nginx as a caching layer, has never come in my thought, even though Nginx is becoming matured in caching. At any day, I'd consider Varnish, over Nginx, for caching, due to the flexibility to configure Varnish to do various things.

  13. eric-o
    Member
    Posted 1 year ago #

    I think the technology discussion here is very interesting, thank you!

    But I thought I'd just note here that the question of using a separate admin server is not impossible. I've so far managed to get it working pretty well. The short version is that I this trick outlined on stackexchange to get SSL onto a separate domain.

    I then added an .htaccess rule to fix previews on the ssl box:

    RewriteCond %{HTTP_HOST} ^public.domain.com$ [NC]
    RewriteCond %{QUERY_STRING} .*(/?preview=true.*) [OR]
    RewriteCond %{QUERY_STRING} (.*&preview=true.*) [NC]
    RewriteRule ^(.*)$ http://secure.domain.com/$1$2  [L,R=301]

    Both machines are pointing to the same database. You do need to disable cron on the slave machines so they don't duplicate tasks.

    I have yet to lock down the file system on the apache app server so that it is read only and copied over with rsync. But it is getting close to working. I'd be curious, still, if anyone had any warnings as to why this might be a bad idea or why this isn't often done. It seems like a nice system...and hey, i can get into my panel even when things are pretty busy on the public site.

    -eric

  14. Matt Pramschufer
    Member
    Posted 5 months ago #

    Eric,
    Did you make any progress on this other than what you mentioned previously. I am very interested in hearing more about your approach.

  15. eric-o
    Member
    Posted 5 months ago #

    I did end up figuring out a very nice solution, though it was not simple. It involved creating two separate plugins that I have not made public, but would be willing to share if you message me privately.

    The essence of the approach I used was this:

    1) I created a faceless always-on plugin that directed ssl traffic to one site and non-ssl traffic to a server pool. The basic framework of that plugin was from the stack exchange post I noted above: http://wordpress.stackexchange.com/questions/38902/use-a-different-domain-for-ssl

    2) I created a second plugin to replace several commands in pluggable.php that deal with the login cookies as described in http://www.seriouslyproductions.com/512/securing-wordpress-admin-via-ssl-using-a-separate-admin-subdomain/

    3) I created a set of rsync scripts to synchronize the important directories that need to be updated at a local level.

    These things together allow one to separate out the admin and server functions of wordpress and run it successfully on several (virtual) machines. It is not for the fright-of-heart, but it is really nice to not have one's admin panel exposed to the internet.

    I am afraid I can't do a step-by-step guide, but that should get you started. If you have experience writing plugins, I'd be happy to share my crude code for doing this if you had interest in making an official plugin.

    cheers,
    Eric

Topic Closed

This topic has been closed to new replies.

About this Topic