Half-Elf on Tech

Thoughts From a Professional Lesbian

Author: Ipstenu (Mika Epstein)

  • DreamUp Security

    DreamUp Security

    Not that long ago, I did a ‘DreamUp’ for my company, where we held a Google Hangout and I talked about WordPress security and how to be smarter about things. You can catch the video here:

    http://www.youtube.com/watch?v=Uu-3-o80rEE

    One thing I tried not to do was to list too many plugins and too much code because a lot of security talks are about how we’re all dooooomed, learn all this code. The concept of security is to be smarter about things, so to simplify it, I wanted to talk about the silly things we all do that make us LESS secure, and how to start thinking about what we do to know it’s smarter.

    Here are some of the links from my talk:

  • Diving Into Varnish

    Diving Into Varnish

    We use it at DreamPress a lot, and I’m still learning its ways, but with me, the best way to learn a thing is to do a thing. So when I had a random server crash with nginxcp, I decided to play around and see about using Varnish on my server instead.

    Varnish's banner is a flying bunny

    Varnish is an HTTP accelerator designed for content-heavy dynamic web sites (like WordPress). Unlike nginx, there’s no support for SPDY or SSL, which I can’t use anyway unless I spring for another server in front of my Apache box to be a true nginx box. Since I wasn’t getting any benefits out of nginx for those, I’m not too worried about it here yet. Should the world go to SSL, then my POV will change. The Varnish gurus aren’t fans of SPDY as it happens, which I find fascinating.

    Back on point. I’m going to use Varnish as a proxy, which means when someone comes to my server to ask for a file, Varnish will first check itself for a cache and then if it’s found, serve it without touching Apache. Apache is slow. This is good! While nginx can handle static files rather well, I found that where I ht slowness people told me to use a CDN. That’s nice, but I don’t want to right now, so it makes nginx less of a draw. On the other hand, Varnish will fill in the gap where Apache + mod_php == poor static-file performance. And yes, I’m using mod_php.

    Installing Varnish

    First change Apache non-SSL port to 8080. I’m on WHM for this particular box, so I go to WHM -> Server Configurarion -> Tweak Settings and set value of field Apache non-SSL IP/port to 8080

    Next I install the Varnish RPM for RedHat REL6. This can be either Varnish 3x or 4x, but I picked the latest version.

    rpm --nosignature -i https://repo.varnish-cache.org/redhat/varnish-4.0.el6.rpm
    yum install varnish
    

    Edit the config file – /etc/sysconfig/varnish – and set the VARNISH_LISTEN_PORT to 80.

    Now we edit /etc/varnish/default.vcl with what we want.

    Deep breath. A whole heckuvalot changed from 3.x to 4.x and it took me a couple hours to bang out, since my examples were all from Varnish 3.x. In the end, I made my own fork of DreamHost’s Varnish VCL. Grab my Varnish VCL Collection and I use the wordpress-example.vcl as my default. It’s a whole ‘nother post on how I did that one. A lot of trial and error.

    The default VCL is skewed to WordPress in a specific way: If you’re logged in or have a cookie that isn’t the default WP cookie, or are on SSL, you do not get cached pages. This means my site will be slower for me.

    Configuring Your CMS

    Speaking of WordPress… Here’s the major difference between it an nginx: I need a plugin for WordPress. I took over Varnish HTTP Purge last year in order to fix it (instead of fork it) for DreamPress, and in doing so I’ve added a lot of little tweaks, like a ‘purge all’ feature and a button on the toolbar.

    Oddly, this is the reason I didn’t want to use Varnish. Where nginx just works, needing a plugin means I have to either install and activate for everyone using WordPress or any other CMS on my system, or I have to figure out a way to not need a plugin? Oh, and I don’t just used WordPress. Ugh.

    This is moderately trivial to do with Mediawiki but I came up full short when I looked at Zenphoto. While I don’t post often to it (once a week generally), I do post a lot of data and I need the purge to be done. Certainly I could code in a system for it, like I did with WordPress, using a CURL call.

    But it’s the need to do that for Varnish that made me make faces.

    Not using Varnish

    At the end of the day, while I did get Varnish up and running, I chose not to use it. Yet. I have to overcome some hurdles with other apps not knowing how to play well with purging, and figure out how to command purges like I do with WordPress. You can see I have my work cut out for me porting a WordPress plugin to Zenphoto.

    In addition, I’m not really sure I like the fact that I have to do that. Certainly I can just let the cache expire on it’s own, but that seems to somewhat defeat the purpose of having it be able to handle dynamism as well as it does if it can’t magically detect when my content changes, and the cache needs a bump.

  • Mailbag: Multisite Theme Activation

    Mailbag: Multisite Theme Activation

    Briany from Ireland has a cool idea (put the guilt away, Briany, I think this is a pretty wild concept and I like it). This is the sort of ‘support’ email I love because it’s not a yes/no answer, but a theoretical concept to think about and parse!

    Painted corner, peeling

    Here’s the meat of the email:

    SO MY FASCINATING QUESTION IS THIS; In a multi site network is there any way to use 2 separate themes for each or any sub-site based on the URL used (or any other method) Example 1 Visit www.sitename.platform.com and view the whole site using theme A (Standard) Visit www.sitename.com and view the whole site using theme B (custom)

    At first I thought “Briany can’t possibly be asking ‘How do I activate a separate theme per site.’” and then I realized the question was for the network! So to phrase it in WordPress terms, if I visit the site via foo.example.com, I get theme foo on every site on the network.

    (If you just want Site A to have one theme, and Site B another, that’s easy. Either network activate the theme and select it on the site, or go to WP Admin -> Network -> Sites, click on edit, click on the themes tab, and activate the theme you want for the sites. Then go back to the site and select that theme. A couple steps, yes, but relatively easy.)

    Theoretically yes, yes you can. There’s a plugin called Theme Switcher which lets users pick, and based on some code on StackExchange, you can change the theme based on users, but the issue here is that you want to only change it per domain for that user.

    It’s certainly possible to change settings by detecting the domain, I do that with SSL.

    if ( $_SERVER["HTTP_HOST"] == "foo.example.com" ) {
        // My Code Here
    }
    

    That’s the easy part. The hard part is keeping that setting when I go from foo.example.com to example.com…

    I sat and kicked this idea around for a while. It would be much easier on a single install of WordPress, since I could make everything relative and then just use the host name. But you have to have a way to track the starter domain, and have it be per-visitor, which means you have to use cookies, and read from that, using setcookie() (which is a PHP thing, not WP specific).

    At that point, I think I would close the book and say “No, it’s possible, but not a good idea.”

    Why, you ask? Caching. How the hairy hell could I possibly cache that if the theme changes every time for every user? Maybe, maybe, I would do it with multi-networks, and define a theme per network, but not per-domain. Obviating any caching would pretty much kill my sites, and even a good opcode cache (I use memcache) will be usless in that scenario.

    By the way, there are a lot of neato plugins to change themes based on weird things, like Domain Theme, which is great for single installs of WordPress.

  • When Sites Go Down

    When Sites Go Down

    My webhost had a bad day. They ran a regular, normal, upgrade to some switches and a switch failed. It decided it would be fun to reboot over and over. Since running on one switch is rather dangerous, they decided to roll back so we could have two and everything would be okay. It didn’t work. In fact, nothing worked. It was one of those days where you put out a fire only to have an earthquake, and as soon as you got the place cleaned up there was a flood. And then the sprinklers thought they should go off.

    We have, every last one of is, had a day like that. A day where absolutely everything went wrong when it was possible to do so. It was clearly one of those days.

    I can certainly complain that my host wasn’t really the best when it came to explaining things, too. They would send us emails, which was fine, except my emails were on my server which was inaccessible to me. So many people went to their live-chat that it was impossible to get a rep. Tweets? Unanswerable due to volume. They actually replied by (heh) email. And when I went to their management panel on their website, it just said that it would be updated in ‘an hour.’

    I resorted to opening a ticket. And I hated doing it, since I knew better than many exactly how shitty their say was. So I asked “Status Update?” and explained that I was unable to check my email but what was the status? I got the form replies, which I expected, and I pushed back for one detail. Just one:

    “It is our aim to have this completed within the next hour by proceeding with this fix immediately.”

    Hour from when?

    Suggestion for your website: Can you timestamp things so we know when to kind of expect things?

    By the end of that day, they had a static.html page with the information, and times(!), on it. They’re not ‘great’ at keeping it updated, but I know how annoying that aspect is, and I don’t fault them one bit. Once the work was done and everything was back to normal, I inquired as to the offered credit, which actually I’d forgotten about but they had mentioned to me in the support ticket! I think it works out to being about $4, clearly not very much, and honestly I don’t care about it very much.

    A thought that never crossed my mind? Leaving them.

    It’s not because my server’s been there for over a decade, and it’s not because I like the more and more ‘grown up’ corporate tone of their communications. It’s certainly not that I agree with everything they do. But what I do agree with is that I pay them for a service and, for the most part, I get it. When I don’t, after the dust settles, they’re as responsive as every other host.

    I’m not paying them just for server space, after all. I pay for backups, some cloud services, and most of all, I’m paying them for help when I screw up. Not to be my consultants, certainly, but I do pay them for technical support and advice like “Can you tell me how to install Ruby on my server?” because there’s no KB article … yet. Also when I needed help tuning httpd.conf they helped out. They don’t do the work for me, they do their limit, and they’re generally friendly about it.

    Someone playing an acoustic guitar

    So how bad does an incident have to be to make me leave it?

    I’ve only ever left a host when they didn’t offer the services I needed (SQL, PHP 5, so on and so forth). If I was paying less for a bare-bones host, I’d have to pay someone to help me with server stuff anyway, so for me the all-in-one matters.

    As for outages, I’m pretty relaxed about it, At an hour of downtime, I pay attention. I had a total of about 4 hours over the course of a day, which is annoying, and bad, but not horrible because no content was lost, just traffic. It’s not that my website isn’t my life, it’s that I’m realistic about situations. If the host explains what happened and are working on fix it as fast as is reasonably possible, I’ll suffer up to 6 straight hours before getting really upset. I’ve never had an outage of more than 75 minutes in a row, though, and before this one, I never had one more than 45. So yes, this was the worst outage I’ve ever had with them (that wasn’t my fault).

    Other incidents that may make me leave would be a deletion of my server without warning. That, hands down, is time to go. Any service promise that isn’t regularly met is grounds for a chat about expectations. I don’t count ‘support response time’ as a service promise, mind you, since when shit gets bad, that’s always going to drop. I mean things like backups or uptime. I’ve never been one to care about 99% uptime, but if the server’s always crashing no matter what I do, and they’re not willing to help me, then I have a problem. In general, I feel that if my site in particular is having issues, it’s probably me and my snowflake more than them. If all sites have the same problem, then it’s probably our needs don’t match the host services.

    The funny thing is I don’t know of many hosts that fits that bill. Sometimes a host has to tell you no, they can’t offer a service, and sometimes they tell you that you’ll have to pay more to do something. But in general, most hosts want to keep you, they want to help you, and they sometimes have to be the bearer of bad news. I’ve actually met hosts who have told me “We won’t be able to provide you the quality of uptime you need due to the way your site is being accessed.” That was a fancy way to say “You get too much traffic for our small node to handle.” And then they handed me a discount for another host. Another Host. This small host was bought out years ago, but I will always remember Greg for that moment. He was awesome.

    My point is that it’s not my host’s job to manage my website, so if I let the spam on my site go wild and it causes my server to crash, well that was my fault. Not theirs. Don’t like the way my plugins make my site work? That’s on me. And if they tell me “You’re getting hit by Reddit, we need to increase your CPU/memory to handle it, and that will cost you more money” I know they’re not just upselling me.

    There are some hosts, sure, out to make a buck, but in general I find that if they know that I understand our relationship, things go well.

    This isn’t meant to be a love song to any one host. None of them are perfect, and they all have weird quirks. This is a love song about remembering my relationship with my host, respecting that, and holding up my end of the deal. I’m not naming any host names (even though it would take you about 2 seconds to sort out who mine is, and who I work for, and yes, I’m ecstatic about both), because it doesn’t matter. I’ve had an experience like this with hosts that are maligned and vilified. My choice not to use them is not based on quality of service but on my morals and ethics. I chose not to fund people I am diametrically opposed to, for my own peace of mind.

    But I find, for the most part, that when I make it clear I know how our relationship works, and better yet, I know how their job works, I get both the support I want and the results I expect. It’s funny how that goes. They keep my faith and I keep trusting them.

  • Cold Calling Support

    Cold Calling Support

    Recently a coworker said I was mean to support, because I was firm and annoyed with someone on the phone. “Every time I’ve heard you take a support call in the office, you’ve been mean.”

    I corrected him “Those were cold calls. When I call support, with the exception of the idiot I got at NetSol, I usually walk away from my desk so we can have a long, friendly, chat.”

    Basically he only saw me talking to cold callers and thought I was mean. And I get why. Are not cold-calls a part of support? Given that cold-calling people who didn’t pay for (and who paid but never used) hosting, I can see where he might be taking it personally. I didn’t mention, since we both agreed that surveys calling you and offering to pay you was shady at best, but I don’t see what he does as a cold call. Debt collection maybe, but he’s not a cold call. He’s calling you because he has your information and you already started a relationship with us.

    So why do I hate cold calls? Well it’s the same reason I generally hate the emails “Can I ask you for a debugging favor?” You’re trying to get something off me without compensation, or generally thanks (no, Anne and Benny, you were fine). A cold call is even worse, though, because it really is just an out of nowhere call.

    Whats an example of the worst kind of cold call? Phone scams. I actually get a lot of those for services I don’t use, like Microsoft, and it’s actually made me tell people when there are legit calls “If you’re calling from X company, I’m going to call you back at the main contact number. What case number can I reference?” I did that with the cold-call for a debt collection which I argued. I didn’t recognize them, I didn’t know them, and I was not about to give them my credit card info over the phone.

    I got into an argument with a fake Microsoft call recently. “Sir, let me stop you. You’re calling someone who works in IT. I don’t have a Windows computer, you’re working for a scam company. I know many good companies in India–”

    And he shouted at me “I am not in India. Please listen, your computer has a virus.”

    So I raised my voice, “Sir, no it does not. You are working for a scam–”

    And he screamed, “YOU ARE A SCAM!” My wife could hear him. I tried to cut him off and explain, he shouted insults (I used to work with people from India, I know some insults) and I hung up.

    Hand holding a phone

    I’m sure I could have been nicer. Equally I could be nicer to the salespeople from DirecTV who call. “We’d like to upgrade your service.” and I say no thank you. “But it’s free for 3 months.” And I know that, but I know in 3 months I have to remember to cancel the service. No thank you. Again, no thank you. It’s around the second ‘no thank you’ that I start to lose my patience. Certainly I try to be firm, so they don’t think I’m easy to convince, but I’m not trying to be mean.

    It’s possibly a side effect of ‘Bitchy Resting Face.’ Whenever I’m firm and direct and say “No, I don’t want that service.” I get push back that I’ve been mean to the person on the phone. But if I say the same thing in a sweet and kind voice, I’m told I’m being too soft and that encourages the hard sell. From my end, it’s a no win.

    This is probably why I’m a bad salesman. If I say “You may be interested in product ABC, it can do these things.” and the person says “No, thank you.” I stop. I may say “Okay, if you change your mind or have later questions, please just ask.” and I move on. Because I, personally, hate the hard sell. I don’t want someone convincing me I want something I don’t need. Sales calls are not something I appreciate.

    On the other hand, of the few times I’ve been called by companies for support (not the other way around), I’m cautious and then pleasent. When I moved to California, my bank and credit cards called me. “Hi, we’re seeing a lot of charges from your card in a new location.” I laughed and asked if it was my new city and if it was the Target. They said it was, I assured them that was me. “Well, we’re going to hold those transactions until you update your account with your new address.”

    Boom. That was awesome. Security and support in one. I had to update it, of course, but in doing to, I confirmed for them it was me, and I helped them out. This was good because the next week someone in Kentucky tried to use my card numbers and they knew it wasn’t me. Of course, the amount of travel I do makes this hard, but they keep checking with me when appropriate.

    And that support? I always smile for.

  • Mailbag: Multisite Files

    Mailbag: Multisite Files

    Another mailbag! This one is a few people… No, this is the one most people ask me. I understand why.

    I really do understand it’s intent, it’s goals, and I try to keep up with it. I use it daily. When I write plugins for it, I spend hours trying to decide how to properly support it. I may even write in checks on the ones that don’t work on Multisite to auto-fail when you activate and prevent you from using them. I will argue till the cows come home that Multisite is for multiple separate sites. But that said, there’s also an exception to every single rule.

    A bunch of envelopes

    Let’s get to the letter! Kevin in Canada has a Multisite with a uploaded files conflict:

    The site is setup as default /files for the upload dir. Problem is, my client already has a directory in the root called /files. It cannot be changed as it houses software exe’s and needs to remain as /files. I need to set the upload path to /media for the images and not mess the site up. I read your blog post about this issue but wondering if you could clarify the steps. Right now, software download requests are redirected to the homepage!

    The steps are, alas, complicated because the situation is complicated. The blog post Kevin’s referring to is called Dumping ms-files. If you’ve installed WordPress as of WP 3.5, this is the new default anyway. That would mean that Kevin has an old Multisite.

    The ‘easiest’ option would be to start over with Multisite, use a fresh install of 3.9 and go from there. Second to that? Well the dumping MS files stuff is not easy and it really can’t be easy. You can try trepmal’s directions but after that you’re getting into writing a little bit of your own custom directions, and that is going to be really complicated.

    I’m not 100% clear on why these can’t be moved, so I’m guessing that the issue is the lost redirections. While I believe good URLs never change, I think that redirecting them is okay. These are .exe files, which means if, before the .htaccess rules for WordPress, you were to put in a rewrite rule and check ‘If you’re looking for /files/*.exe, go to /otherlocation/filename instead’ that might get around it, or even to say ‘if files and NOT exe.’ Maybe something like this:

    # uploaded files
    RewriteCond $1 !\.(exe)
    RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]
    

    Mind you it’s weird. Either you had Multisite first, which would explain the /files/ for uploads, or you had the EXEs in /files/ first, which doesn’t explain how you got this far into it at all, since 3.5 came out in December 2012, and that would imply you built the Multisite in 2012 and have had this problem for at least 18 months, give or take, which is a long time to have a problem and do nothing about it.

    If you started with WP 3.5 or later, you just make a /files/ folder and off you go, no code needed. If you started before that, you can follow the directs to undo MS files and then make a files folder and be done. Make sure not to forget about the .htaccess rules!