Blog

  • Nginx Configuration Files for Laravel Valet

    I switched to Laravel Valet for local WordPress development on my Macbook in December 2019. I love it. I presented at January’s WordPress Lancaster meetup about how and why I made the move.

    This week, I’ve written some code that protects uploads to the WordPress Media Library. (Did you know that anyone can view uploads if they find the URLs? The Media Library uses only security by obscurity.) To code my solution, I’m using an .htaccess file to protect a subfolder in wp-content/uploads.

    There is No .htaccess in Nginx

    .htaccess files do not work in Laravel Valet because it uses the nginx web server instead of Apache. (And, Valet does not use a reverse proxy to allow Apache features to work while running the faster nginx.) nginx does not allow its configuration to be changed on-the-fly, and that’s one reason it’s faster than Apache.

    To replicate the protected folder mechanism, I learned how to block access to a directory inside an nginx configuration file, but that introduced a new challenge: Where is the nginx configuration file? Most resources will identify usr/local/etc/nginx/nginx.conf as the configuration file, and while that’s correct, changing it and restarting Valet did not change the behavior of the folder.

    Nginx Config File Location for Laravel Valet

    Each site you create inside Valet gets its own configuration file at this location: ~/.config/valet/Nginx/sitename.test This is the file you should edit.

    Restart Valet to Allow Configuration Changes to be Loaded

    Nginx needs to be restarted in order for configuration changes to take effect, and I found it easy to use this command inside Terminal: valet restart

  • Customizing a Durgod Keyboard for macOS

    I recently bought my first mechanical keyboard. The COVID-19 pandemic means I’m switching between my Macbook and a Windows machine throughout the week at the same desk, and while I was comfortable typing on the Macbook, this HP Spectre keyboard and I do not get along. The differences in shortcuts for copy and paste alone were causing me to make enough mistakes to know it was time to invest in a peripheral keyboard.

    Alas, I’ve made the leap to a mechanical keyboard, a Durgod K320 in space grey with Cherry Silent Red switches (120$ shipped). Typically, I’m the kind of guy who buys whatever Wirecutter recommends, but their suggestions for mechanical keyboards are bad ones.

    Features you Should Demand of a Mechanical Keyboard

    • the ability to remap any key
    • multiple profiles of key mappings

    Wirecutter recommends the Varmilo VA87M and the Leopold FC750R. I couldn’t determine if these keyboards include software that makes it easy to remap keys while shopping. The Leopold’s keycaps don’t have legends for the multimedia controls of the function keys, so users will have to memorize the alternate roles of F5 through F12, print their own legend, or change the keycaps. I can’t support these accessibility shortcomings.

    Durgod Zeus Engine Only Runs on Windows

    The keyboard I bought has companion software to customize the key map and save multiple profiles. That software is called Durgod Zeus Engine, and it only runs on Windows. That might be a showstopper for some, but not I. The current version of Zeus Engine is 1.0.2.12, and it is much better easier to use compared to when I first bought this keyboard.

    The changes I’ve made to make this keyboard macOS friendly are as follows:

    1. Swap Left Ctrl and Left Windows keys (macOS’ command defaults to the Left Windows key instead of Alt, which is weird and why freedom to customize is important.)
      1. Ctrl = 224
      2. Windows = 17

    Use the website https://keycode.info/ to reveal what your keys are actually doing.

    How to Switch Between Profiles

    Hold Fn and press F12. The M light will illuminate to confirm the alternate profile activation.