macOS X and its successors have been around since 2001, but those of us who used Apple’s computers in the 20th century remember even earlier versions of the operating system. Designer Michael Feeney imagines what it might have been like if today’s apps ran on the more primitive user interface of macOS 9.
Once you have an SSL certificate configured, the next step is to redirect unencrypted traffic. There are several methods of doing this. Within your application (Laravel), by the web server (Apache or Nginx) or by the frontend (load balancer). This article will redirect HTTP requests to HTTPS in Laravel using middleware.
If you are also deploying a frontend load balancer, configure both HTTP and HTTPS frontends. In most cases, you will forward traffic from the load balancer to the backend (Laravel) via HTTP and not by HTTPS. This is called SSL Offloading. This means your Laravel middleware must detect the protocol (HTTP or HTTPS) that the client connected to the load balancer and ignore the protocol that the load balancer is using to connect to the backend. Otherwise, the middleware will detect HTTP even if the client connected to the load balancer using HTTPS, and the client will go into a redirect loop.
In this article, I will use yourdomain.com. Replace with your domain name.
Laravel middleware only supports files served by routes. Files that are not served by Laravel, such as /js/app.js will NOT be redirected. This is one of the reasons I like to have HTTP Redirection as several layers (load balancer, web server, application framework). Another reason is to ensure that more than one service layer enforces HTTP Redirection.
Configure .env
This article supports two environments, development and production. The development settings will not redirect HTTP to HTTPS. The production environment will redirect. The environment will be detected by the APP_ENV setting.
Production Configuration:
APP_ENV=production
APP_DEBUG=false
APP_URL=https://yourdomain.com
Development Configuration:
APP_ENV=local
APP_DEBUG=true
APP_URL=http://localhost:8000
The application environment labels local and production are used to enable/disable certain features in Laravel.
Initial Testing
Open a web browser and connect to your site via HTTP: http://yourdomain.com. Verify that your site loads correctly, and you are not redirected to HTTPS. Note: some TLD domains such as .dev automatically redirect in browsers. If this is the case for you, use the curl command method below.
Open a command prompt and run this command:
curl–Ihttp://yourdomain.com
We are interested in the first part of the output which is the HTTP status code. If HTTP redirection is disabled, you should receive a 200 response:
For this article, we want a 200 response so that we can implement and test HTTP redirection.
If HTTP redirection is enabled, then you will receive a 3xx response with an HTTP Location header:
HTTP/1.1302Found
....
Location:https://yourdomain.com
Before continuing, disable redirects in your web server or frontend (load balancer). Save your changes, so that you can reenable redirection at the frontend or at the webserver.
Note: browsers tend to cache HTTP redirects. You might need to disable the browser cache.
Disable Chrome Cache
Open the Chrome Developer Tools (F12).
Go to the Network tab and make sure Disable cache is ticked.
Keep the Developer Tools open while testing.
Create the Middleware
Using artisan create the middleware template:
php artisan make:middleware HttpRedirect
This creates the file app/Http/Middleware/HttpRedirect.php.
Edit App/Http/Kernel.php and add the middleware to $middleware:
protected$middleware=[
...
\App\Http\Middleware\HttpRedirect::class,
Clear the configuration:
php artisan optimize:clear
Supporting Proxy Frontends
If you are using a load balancer that connects to your Laravel backend using HTTP, detect the HTTP header X-Forwarded-Proto. Use this code for the handle() function instead:
If your Laravel application does not have a proxy (load balancer) accepting traffic, do not add the proxy code. A smart hacker could manually add the header X-Forwarded-Proto and bypass the HTTP Redirect feature.
If you allow your Laravel backend to be accessed from a load balancer and directly from the Internet, add logic to only process the X-Forwarded-Proto header if the request arrives from a known frontend. Google Cloud HTTP(S) Load Balancers use the 130.211.0.0/22 and 35.191.0.0/16 IP address ranges.
Additional Options
The above middleware will redirect requests that are handled by Laravel routes. I also recommend that Laravel always generate content using HTTPS based URLs. Examples are JavaScript and CSS references.
Edit app/Providers/AppServiceProvider.php
Near the top add:
useIlluminate\Support\Facades\App;
useURL;
Add the following code to the boot function:
publicfunctionboot()
{
if(App::environment([‘staging’,‘production’])){
URL::forceScheme(‘https’);
}
}
Summary
I prefer to implement multiple layers of security. When implementing HTTP Redirection, I try to implement this feature at each service layer. Starting with the backend (Laravel), then with the web server (Apache or Nginx), and finally at the load balancer. Sometimes mistakes are made, and one layer might disable HTTP Redirection. By enabling this feature in more than one service, I have a higher confidence level that clients’ data is and remains encrypted.
Photography Credits
I write free articles about technology. Recently, I learned about Pexels.com which provides free images. The image in this article is courtesy of Pixabay at Pexels.
I design software for enterprise-class systems and data centers. My background is 30+ years in storage (SCSI, FC, iSCSI, disk arrays, imaging) virtualization. 20+ years in identity, security, and forensics.
For the past 14+ years, I have been working in the cloud (AWS, Azure, Google, Alibaba, IBM, Oracle) designing hybrid and multi-cloud software solutions. I am an MVP/GDE with several.
This year 3D printing continued its inexorable rise as a powerful, game-changing fabrication technique. Two areas were of interest to us: Pro-level advances achieved by corporations or universities, and the experiments, improved techniques and innovative objects produced by individuals or small teams.
This year we learned about Desktop Metal’s binder jetting, a 3D printing process that uses inkjet print heads to deposit a liquid binding agent onto a powder bed. It can be roughly 100 times faster than laser powder bed fusion systems (see side-by-side comparison below) and looks to be a gamechanger.
The second season of Netflix’s The Witcherbrings a lot of good material with it, from the growing relationship between Geralt (Henry Cavill) and Ciri (Freya Allan) to Yennefer (Anya Chalotra) growing into her magical power. For Geralt and Ciri in particular, a lot of their relationship is rooted in him training her to become a Witcher at Kaer Morhen, a key location in the books and Geralt’s childhood home.
Netflix has been releasing a series of videos going into the development of Witcher’s sophomore season, and two specifically are focused on the remaining Witchers and Ciri’s character development. After spending the first season running from threat after threat, Allan was excited for Ciri to both “navigate what she wants,” and to finally be involved in the action.
“It’s very difficult to go straight into swordfighting routines,” Allan recalled. “So I had to do quite a bit of training.” When it came time to do actual stunt work, showrunner Lauren Schmidt Hissrich had glowing praise for Allan’s dedication, particularly when it came to the obstacle course at Kaer Morhen. “She couldn’t have loved it more…Watching Freya get knocked physically off of it so many times was pretty incredible and terrifying.”
Though Ciri wants to follow in the footsteps of her surrogate father, he’s not the only Witcher she spends time with throughout the season. Below, the second video shines a spotlight on the other Witchers: Eskel (Basil Eidenbenz), Coen (Yasen Atour), and Lambert (Paul Bullion). All three are fan favorites from the books and games, but they’re all arguably outclassed in terms of importance by Kim Bodnia’s Vesemir, Geralt’s own father figure who starred in the animated prequel Nightmare of the Wolf. Vesemir has been leading the remaining Witchers since the events of the film, and Allan says that over the course of the season, Ciri comes to respect him as much as Geralt does.
Every winter, the remaining Witchers go to Kaer Morhen because it’s where they “feel rooted as a family,” in the words of Paul Billion, who plays Lambert, . The scarcity of their ranks have only made their bonds with each other grow stronger, something you see throughout the season as they help train Ciri and fight monsters together. “It’s about family and exploring what family means,” Bullion continued. “It’s what the Witchers represent.”
G/O Media may get a commission
The family bond is something fans have wanted to see in the show for some time, but the new season has thrown a curve ball that not all are happy with, and have left fans demanding answers.
When Geralt and Ciri arrive at Kaer Morhen in the second episode, the reunion turns grim when it’s revealed that Eskel was infected by a leshen while hunting it down. He’s then killed by Geralt, something that very much doesn’t happen in the books. Speaking on the show’s podcast on YouTube, Schmidt Hissrich discussed how the process of Eskel’s grim fate came to be. They’d known how they always wanted to kill someone, and it was important to make sure it had something to do with Ciri. Regardless of who died, that death had to to force Geralt and the other Witchers to realize her presence here would change things.
Originally, that death was going to be for a brand new character she called “John.” But that death wouldn’t have mattered, so it was changed to Eskel as to really have an affect on Geralt and spur him to truly train Ciri. “I know that there are fans who love Eskel and who feel like, why would we do that?…But honestly, his death is what changes everything for Geralt.” Part of the desire to kill off Eskel and more Witchers was also to drive home the idea of the Witchers being caught up in a constantly changing world. “So much of season two is about the fact of, ‘Is the Witcher brotherhood over?’…Of course we had to kill more.”
Despite how bleak things are for the organization, Schmidt Hissrich believes that Vesemir still has some hope for the future. “There’s this history in Vesemir, he’s the keeper of Witcher history…When Ciri and Vesemir are walking through the Kaer Morhen lab, we hear his retelling of the deaths of the Witchers, and suddenly why he thinks Ciri could be their savior. It’s that type of optimism that’s really important to Vesemir.”
In Laravel 8.76, support for a new `afterRefreshingDatabase` method in tests was added. Want to know when and where to use it? Read on!
A while back, I PR’d a LazilyRefreshDatabase trait to the Laravel Framework. This came from the annoyance of having to manually include RefreshDatabase in each test, unless you wanted to suffer a performance penalty. It was very well received. So well, in fact, that it almost became the default way of refreshing your test database in new Laravel projects. Almost, until it was revealed there was a catch.
For most projects, LazilyRefreshDatabase would work without issue. I had several projects that were updated and running in less than 5 minutes. But on other projects, that wasn’t quite the case.
As an example, take the TestCase from the in-progress PestPHP news site: https://github.com/pestphp/news.pestphp.com/blob/main/tests/TestCase.php. We have a non-standard migration strategy here: before each test, we need to ask Laravel to also migrate Wink’s migration files, then run a seeder.
This would cause a real problem for LazilyRefreshDatabase. Why? Basically, if we did it in the setUp method, we would be completely negating any benefits provided by the LazilyRefreshDatabase trait, because the database would go back to being refreshed after every test. What if instead we use a listener that fires after database migration is complete, like so?
publicfunctionsetUp()
{
parent::setUp();
Event::listen(MigrationsEnded::class,function(){
$this->artisan('migrate',[
'--path'=>'vendor/themsaid/wink/src/Migrations',
]);
});
}
Well, this seems like a good idea, until you run it. What we’ve actually caused here is an endless loop, because the Wink artisan command will cause the MigrationsEnded event to fire again. Not good. Not good at all.
What we actually need is a hook. A hook that will fire after the database has refreshed. A hook that doesn’t care whether you’re using RefreshDatabase or LazilyRefreshDatabase, but rather just works.
That’s exactly what the new afterRefreshingDatabase method does. It will fire once the database has been refreshed (as the name implies), and gives you the perfect location to drop any test setup code like this. By using this method, we keep all of the benefits of lazily refreshing our database whilst allowing for pretty much any database setup, whether that’s additional migrations, seeding or something else, that is required.
So, now you know why and how to use afterRefreshingDatabase in your Laravel tests. Since adding this method to the Laravel Framework, I’ve been able to adopt LazilyRefreshDatabase in all of my projects without any issues!
BETHLEHEM—According to sources, the eternal Word of God has become flesh in the form of a newborn baby who was born this morning.
Some claim that this child is the human incarnation of the God of the Universe, who has come to reconcile a broken creation with its holy Creator, saving a wayward human race in a heroic rescue echoed in myths, legends, prophecies, and whispered hopes since the dawn of time.
If true, then God is with us, and things will never be the same again.
You may recall Remington filed for bankruptcy in 2018 then quickly remerged after restructuring.
But the 200-year-old firearms giant filed once again in 2020,r resulting in a bankruptcy court parting and selling the company.
Remington Arms
The firearms component was bought by Roundhill Group LLC and rebranded as RemArms.
On the other hand, the ammunition side of things was purchased by Vista Outdoor. It’s here in the wooded plains outside Lonoke Arkansas, that our tale begins.
We met a lot of great folks as we toured the facility but were reminded that it’s still a working factory.
I tucked my hair under my hat, kept my hands to myself, and we headed into the 2A equivalent of the Wonka Chocolate Factory.
No Wonkavator, but the elevator in the shot tower was cool.
The Remington grounds sprawled across 1,200 acres and contained multiple sites for building, testing, and even enjoying their products.
The Book of Eli
We learned a lot. Led by our guide Joel, we started in a building called Eli which was named for Eliphalet Remington who founded the company in 1816.
This awesome building was currently assigned to mass-producing 9mm and the machines were whirring away as we toured.
Casings, before primers and bullets.
We saw machines that handled giant coils of brass weighing 4,000 pounds.
The material was stretched, pressed, and snipped into shell casings. Then, different parts of the process added the actual bullet and primer on either end.
At a bullet maker, we spoke with Adam the plant manager who was dealing with a mechanical issue.
The giant clutch for the machine was broken down and only made in Canada.
Here, bullets are installed in the cases.
The techs they needed to work with only spoke French, a graphic example of some of the challenges faced when making ammunition.
Joel explained how coming under the Vista brand has improved things.
Working with sister agencies like Federal, the various ammo manufacturers benefit from cross-pollination — seeing how they can do things better or more efficiently.
Vista inherited some major issues when they took over but their efforts are paying dividends.
Promptly righting the ship, they worked on facility issues and brought bankruptcy furloughed employees back in time for Christmas so they’d have benefits.
The vaunted 8-gauge.
Newly helmed, Remington continued in that trend, hiring 20 people a week, and building up to three shifts in some areas to run the production 24/7 in an effort to match demand.
A month before our visit, Remington shipped out more ammunition than they had in the past five years combined!
Joel estimated their output in the billions of rounds per year.
The view from the shot tower.
And the company is still growing. The Eli building is slated for a skunkworks addition — a section dedicated strictly to R&D, hinting at some exciting developments.
Seeing long tubes of plastic heated, stretched, then cooled in tanks of water and snipped to length offered a fascinating look into the process.
Above all, the shot tower was a highlight. Some 12 stories up, a giant furnace exists strictly to melt lead into molten metal.
It gets hot in the tower with the furnace making shot.
This metal then pours out through filters that form the basic size of the shot. As it drops, it cools. Then it’s collected at the bottom.
We didn’t see this running live because of the heat and risk, but there was plenty of evidence of it running everywhere we looked. Carts, hoppers, and bins of shot were everywhere.
Rimfire
We moved onto rimfire, where Remington steadily churns out rounds.
As I think about it, even during the heightened demand, I never saw a lack of .22 LR or shotgun shells on the shelves in stores.
I would love to show up at the range with one of these hoppers of .22 LR.
This process, like the rest, was really cool. Primers are a whole different situation since they are inclusive to the case.
One of the greatest parts was just seeing enormous amounts of .22 in giant hoppers that probably weight hundreds of pounds.
At several points during this trip, I found myself wondering how long it would take me to shoot various piles of ammo I encountered.
Testing, testing…
One of the cooler stops was down in the underground testing facility where workers indiscriminately test batches of ammo.
They actually pull a sample off the assembly line, load it into a test chamber, and fire it.
Testing apparatus.
Jimmy explained these tests examine the function, pressure, velocity, and accuracy of everything Remington makes.
Just as important, they test for real-world scenarios — freezing and heating ammunition to simulate actual scenarios shooters might face.
Shot “filters”
Most noteworthy was the armory at Jimmy’s fingertips, just about one of everything you could imagine!
With the tour of the facility complete, we headed out to a couple of different ranges where we shot — centerfire rifle out to 200 yards, followed by 9mm through Glocks.
No complaints here.
We also shot rimfire, rifle, and pistol, sampling a good deal of the quality products Remington offers.
Finally, we moved on to a sporting clays course. I shot skeet and trap a little, but never anything this cool.
Giant bars of metal are staged outside the furnace.
The course was as fun as it was humbling and greatly demonstrated an area where I needed a lot of practice.
Conclusion
By the end of the trip, I could appreciate how far Big Green had come. In 2020, the company faced another bankruptcy.
But now, the ammo giant has recovered and is increasing production.
From what we could tell, production was full steam ahead.
Top that off with an intense quality control program and an investment in the future with research and development.
In many ways, Remington benefitted from its separation from the firearms manufacturer of the same name. Now they have their own budget, own direction, and vision.
Coupled with the proven know-how of Vista Outdoors, this American icon is working toward a brighter future.
For a look into the factory, see the video below.
What do you think of Remington? Let us know in the comments below. Still struggling to find ammunition? Check out our guide for the Best Online Places to Buy Ammo.