Rxsavingsllc/Nginx Docker Container
Creating the files to build and run a custom Nginx container to use with php-fpm in for all of our Microservices.
Building the Image from the Dockerfile
To start, we run
docker build -t rxsavingsllc/nginx . within the repository directory in the same place as the Dockerfile.
This image is based off of Nginx Inc's nginx Docker Image and sets up communication with php-fpm.
Running the Container from the Image
To use the image in production, we run
docker run -d rxsavingsllc/nginx.
Make sure that the container is running by running
docker ps to see the active containers. Then, run
docker exec -it <most_recent_active_container> /bin/bash and replace
<most_recent_active_container> with the newest container in
docker ps to access the container.
Created Applications to Link to Nginx
Every application using nginx must have its own vhost defined in a volume at /data/nginx/vhosts/ and every vhost file must include 2 things:
####1. Include Line for Nginx Conf Files
At top of vhost file (not inside server block), add the following line:
include /etc/nginx/addon.d/*.conf; to access Nginx's conf files there.
####2. Add Parameter Line to PHP Section
With the php section (
~ \.php$) of the location block of the server block of the vhost file, add the following parameter:
fastcgi_pass php-upstream; to the rest of the parameters there.