Resources for Developers

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:

location / {
    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 {}.

Tip: You can find more information about extra configuration in the PHP support page.

Redeploy your app

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

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


mode_edit Suggest edits