Docker on Azure - SSH connection

Introduction

There are a lot of tutorials how to create Load Balancer but they are mostly just demos or „hello world” and they are not covering some real life problems.

Main problem is how to work with SSL provided by third party vendor and keep configuration as simply as we can.

Step 1 – create servers

Initially I had just one server which was also configured and active as production server.

To not change it drastically and move everything to docker image or kubernetes (we need to keep in mind that even if this is good from technical point of view we need to stay within customer’s financial limits and time frames) I just made snapshots of main server and create child servers from main. The only difference was that main server will have less resources than child servers.

No alt text provided for this image
No alt text provided for this image

Add child servers to trusted sources in DB server

No alt text provided for this image

Step 2 – adjust nginx config on main server

No alt text provided for this image
No alt text provided for this image

Nginx configuration must be of course reloaded at the end.

Step 3 – adjust nginx config on child servers

This is just standard HTTP (without SSL) configuration for Laravel

No alt text provided for this image

Step 4 – adjust Laravel URL schema

After deployment to PROD I realized that generated URLs and resources are served using HTTP, not HTTPS. That was correct and expected behaviour beacuse child servers are working on port 80.

To fix that two changes are required:

Implement environment definition in Laravel .env file on child servers.

No alt text provided for this image

Cache configuration in order to use config() not env() on child servers.

No alt text provided for this image

Force Laravel to use HTTPS schema on PROD server, to avoid problems on local development environment.

No alt text provided for this image