-
Install Docker: Make sure you have Docker installed on your machine. You can download it from the official Docker website.
-
Run the Docker containers:
docker-compose up
-
Access the application:
-
Open your web browser and visit
http://example.com
andhttp://blog.example.com
. Since this is a local setup, you'll need to update your localhosts
file to map these domains to127.0.0.1
. -
Add the following lines to your
/etc/hosts
file (Linux/macOS) orC:\Windows\System32\drivers\etc\hosts
file (Windows):127.0.0.1 example.com 127.0.0.1 blog.example.com
-
Now, try accessing
http://example.com
andhttp://blog.example.com
again.
-
- What is use of
:ro
in filecompose.yaml
?
In the Docker Compose configuration, the
:ro
at the end of the volume mount (/etc/nginx/nginx.conf:ro
) stands for "read-only." This means that the file or directory from the host machine is mounted into the container in read-only mode. In the case of the Nginx container, thenginx.conf
file is mounted into the container at the path/etc/nginx/nginx.conf
, and it is marked as read-only (:ro
). This ensures that the Nginx container can read the configuration but cannot modify it. It's a good practice to use read-only mounts for configuration files to enhance security and prevent accidental modifications within the container.
- What is use of
proxy_set_header Host $host;
innginx.conf
?
The
proxy_set_header Host $host;
directive in thenginx.conf
file preserves the originalHost
header, ensuring accurate domain/subdomain information when forwarding requests to the Flask application.