Filter IPs allowed to access your app

Introduction

Our PHP deployment stack is using Nginx and PHP-FPM to answer your application request. You can setup IP addresses filtering to allow only some IP address to access your application.

Configuration

Nginx Configuration

Create a directory config in your project:

mkdir config

Edit the file nginx-ips-filtering.conf in this directory with the following content:

allow <ip1>;
allow <ip2>;
deny all;

Last thing you need to do is to instruct Scalingo’s deployment process to use your configuration file.

Deployment Process Configuration

This process requires you to edit the composer.json file of your project. Edit the file the following way:

{
  ...
  "extra": {
    "paas": {
      "nginx-includes": ["config/nginx-ips-filtering.conf"]
    }
  }
}

If you are not using composer, create a composer.json file with the previous content, and also create a file composer.lock containing an empty JSON dictionary {}.

Redeploy Your Application

git add composer.json composer.lock config/nginx-ips-filtering.conf
git commit --message="setup ip filtering"
git push scalingo master

That’s it, only the specified IP addresses will be able to access your app.


Suggest edits

Filter IPs allowed to access your app

©2024 Scalingo