PHPackages                             poing/laravel-elb - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [DevOps &amp; Deployment](/categories/devops)
4. /
5. poing/laravel-elb

ActiveLibrary[DevOps &amp; Deployment](/categories/devops)

poing/laravel-elb
=================

Essentials for Laravel on AWS Elastic Beanstalk with HTTPS

v1.0.3(5y ago)124.5k1[3 issues](https://github.com/poing/laravel-elb/issues)MITPHP

Since Jul 2Pushed 5y agoCompare

[ Source](https://github.com/poing/laravel-elb)[ Packagist](https://packagist.org/packages/poing/laravel-elb)[ RSS](/packages/poing-laravel-elb/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (47)Used By (0)

Running Laravel on AWS Elastic Beanstalk with HTTPS
===================================================

[](#running-laravel-on-aws-elastic-beanstalk-with-https)

This package provides the *essential* elements for a Laravel app running on AWS Elastic Beanstalk `(ELB)` with HTTPS.

It provides the following:

- Environment Configuration Files `.ebextensions` for Deployment
    - Set the document root to `/public`
    - *Example* showing how to read environment configuration variables
    - Copy `.env.aws` to `.env`
    - Run `artisan` commands
    - *How to* install and run `npm` commands
- `defaultStringLength()` for MariaDB or Auroa
- Middleware for HTTP to HTTPS redirection
    - *Includes the ability to configure exceptions to the HTTPS redirection*
- Middleware to recognize **secure** requests

Elastic Beanstalk with HTTPS Quick Start Guide
----------------------------------------------

[](#elastic-beanstalk-with-https-quick-start-guide)

Here are [Step-by-Step](GUIDE.md) instructions to deploy a *new* Laravel application to AWS Elastic Beanstalk.

Installation
------------

[](#installation)

You can install this package using [composer](https://getcomposer.org/)

```
# With the Suggested Packages
composer require czproject/git-php ocramius/package-versions poing/laravel-elb

# Without the Suggested Packages
composer require poing/laravel-elb
```

#### Commands:

[](#commands)

Once the package is installed, the following `artisan` commands will be available in your Laravel application:

- **`elb:install`**: Add `.ebextensions` directory and `.env.aws` to the Laravel application.
- **`elb:publish`**: Add `config/laravel-elb.php` to the Laravel application, to allow HTTPS redirection customization.
    - This will **disable** the *sample* `route` and `view` included with the package.

Elastic Beanstalk Configuration Files
-------------------------------------

[](#elastic-beanstalk-configuration-files)

This package provides Elastic Beanstalk configuration files (.ebextensions) to configure the environment, customize AWS resources, and perform Laravel tasks. *Like running `artisan` commands.*

```
.ebextensions/10-document-root.config
.ebextensions/20-app-key-test.config
.ebextensions/30-env-file.config
.ebextensions/40-artisan.config
.ebextensions/50-node-npm-gulp.config

```

These provide the **basic** requirements for deploying Laravel to Elastic Beanstalk. Files are named so you can insert files *within* the processing order.

> If you think something is missing, something *could* be done better, feel free to submit a pull request.
> *Except for `HTTP` to `HTTPS` redirect, see the next section for an explanation.*

MariaDB or Auroa
----------------

[](#mariadb-or-auroa)

Because I *often* use Auroa or MarieDB, instead of MySQL. I added the *fix* for non-MySQL Databases.

```
Schema::defaultStringLength(191);
```

> Laravel 5.4 made a change to the default database character set, and it’s now utf8mb4 which includes support for storing emojis. This only affects new applications and as long as you are running MySQL v5.7.7 and higher you do not need to do anything.

While AWS does provide a higher version of MySQL. Aurora (*MySQL Compatabe*), does **not** support the increased string length. *yet*

HTTP to HTTPS Redirection
-------------------------

[](#http-to-https-redirection)

Middleware included in this package *eliminates* the necessity of using `.ebextensions` to handle `HTTP` to `HTTPS` redirection with the Apache `RewriteEngine` method. While allowing *some* traffic **not** to be redirected, *such as the Elastic Beanstalk HealthChecker*.

Redirection **does not** occur for ***any*** of the following conditions:

- The `User-Agent` is the Elastic Beanstalk HealthChecker
- The Application Environment `APP_ENV` is set to `local`
- The `URI` matches the `exclude` configuration settings

It provides the *same* functionality as the [`https-redirect`](https://github.com/awsdocs/elastic-beanstalk-samples/blob/master/configuration-files/aws-provided/security-configuration/https-redirect/php/https-redirect-php.config) recommended in the AWS [documentation](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/configuring-https-httpredirect.html), *and allows for custom paths to easily be excluded.*

You *may* choose to use the `.ebextensions` method, it *should not* affect this middleware.

> The middleware is a result of *frustration* trying to get the correct `RewriteCond` rules to **exclude** multiple conditions using the `.ebextensions` method. Handling the `HTTP` to `HTTPS` redirection with Laravel provides more *flexibility* with less headaches. *I was working with an application that could **not** fetch content from third party domains with HTTPS.*

- *This package **does not** prevent `HTTPS` access.*
- *It **does not** redirect `HTTPS` to `HTTP`.*
- *It **only** allows `HTTP` access to the specified `URI` paths.*

### Basic Usage

[](#basic-usage)

*By default*, this package includes a *sample* `view` and allows `HTTP` access to `URI`'s with a base of `/unsecure`.

```
// Green = HTTP Allowed, Red = Redirected to HTTPS
+ http://{domain.tld}/unsecure
+ http://{domain.tld}/unsecure/your/web/route
- http://{domain.tld}/
- http://{domain.tld}/other
```

#### Configuration

[](#configuration)

To use your own configuration, run `elb:publish` to install `config/laravel-elb.php` in your Laravel application.

```
php artisan elb:publish

```

> This will **disable** the *sample* `view` included with the package.

##### Excluded URI Paths

[](#excluded-uri-paths)

- **`exclude`**: An array of `URI` paths that are **not** redirected to `HTTPS`.
    - **Empty array will redirect all `HTTP` to `HTTPS`.**

```
    'exclude' => [ 'alpha', 'bravo/charlie', ],

```

###### Behaviour:

[](#behaviour)

```
// Green = HTTP Allowed, Red = Redirected to HTTPS
+ http://{domain.tld}/alpha
+ http://{domain.tld}/alpha/any/path
- http://{domain.tld}/bravo
+ http://{domain.tld}/bravo/charlie
+ http://{domain.tld}/bravo/charlie/any/path
- http://{domain.tld}/bravo/any
```

##### Strict Mode

[](#strict-mode)

- **`strict`**: Boolean setting that will limit the path to **only** those *specified* in the `exclude` setting.

```
    'exclude' => [ 'alpha', 'bravo/charlie', ],
    'strict' => true,

```

###### Behaviour:

[](#behaviour-1)

```
// Green = HTTP Allowed, Red = Redirected to HTTPS
+ http://{domain.tld}/alpha
- http://{domain.tld}/alpha/any/path
- http://{domain.tld}/bravo
+ http://{domain.tld}/bravo/charlie
- http://{domain.tld}/bravo/charlie/any/path
- http://{domain.tld}/bravo/any
```

Recognizing Secure Requests
---------------------------

[](#recognizing-secure-requests)

The AWS Elastic Beanstalk environment uses a Load Balancer to serve `HTTPS` requests, while the Laravel application *actually* runs in an AWS Elastic Beanstalk environment that **only** supports `HTTP`.

This can cause the Laravel application to *represent* `HTTP` to helper methods that return `URL` information, since the Laravel application is **not aware** of the Load Balancer.

###### Incorrect Response:

[](#incorrect-response)

```
// https://domain.tld
url()->current(); // Returns: 'http://domain.tld'
```

This package uses [`peppeocchi/laravel-elb-middleware`](https://github.com/peppeocchi/laravel-elb-middleware) to *simplify* using `HTTPS` with your Laravel application on AWS Elastic Beanstalk. Ensuring that your Laravel application will correctly recognize **secure** requests when running on Elastic Beanstalk with a Load Balancer. *Allowing helper methods that return `URL` information, to represent the correct protocol `scheme`.*

###### Correct Response:

[](#correct-response)

```
// https://domain.tld
url()->current(); // Returns: 'https://domain.tld'
```

This middleware is *based* on a [gist](https://gist.github.com/peppeocchi/4f522663d7e88029daeba833c835df3d) by [Giuseppe Occhipinti](https://github.com/peppeocchi) that does the exact same thing.

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance15

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~9 days

Recently: every ~104 days

Total

46

Last Release

2093d ago

Major Versions

v0.1.22 → v1.0.02019-07-06

0.1.2.x-dev → v1.0.32020-08-24

### Community

Maintainers

![](https://www.gravatar.com/avatar/cf9e48d0cc39504a157d0ac0d80caf504689caa71c81f9a0504da1999a9c5e25?d=identicon)[poing](/maintainers/poing)

---

Top Contributors

[![poing](https://avatars.githubusercontent.com/u/11417007?v=4)](https://github.com/poing "poing (252 commits)")

### Embed Badge

![Health badge](/badges/poing-laravel-elb/health.svg)

```
[![Health](https://phpackages.com/badges/poing-laravel-elb/health.svg)](https://phpackages.com/packages/poing-laravel-elb)
```

###  Alternatives

[slimkit/plus

The Plus(ThinkSNS+) is a powerful, easy-to-develop social system built with Laravel.

2.2k2.4k](/packages/slimkit-plus)[laravel-fans/docker

Full Laravel production environment for Docker

4311.3k](/packages/laravel-fans-docker)[downtoworld/laravel-devops

Laravel Cloudflare-Tunnels Ready Production Docker-Compose

161.1k](/packages/downtoworld-laravel-devops)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
