Friday, 23 September 2022

docker-compose -mapp file/folder not existed in docker will auto create them, httpd reverse proxy with different url, and virutal host and log position, and http.conf user,group

Docker mapping not created file/folder from your dir to container will auto create them in container for example :

     volumes:

      - ./httpd/httpd.conf:/usr/local/apache2/conf/httpd.conf

      - ./httpd/sites:/usr/local/apache2/conf/sites

      - ./httpd/certs/server.crt:/usr/local/apache2/conf/server.crt

      - ./httpd/certs/server.key:/usr/local/apache2/conf/server.key

      - ./httpd/custom_log:/usr/local/apache2/custom_log


sites folder, custom_log folder will be created, and server.crt, server.key files will be created in container 

For multiple virtual host,

in your volume mapped to container, just create multiple files with different domain, and apache will match based on current site domain name for example :

in httpd/sites:

mysiteA.conf

<virtualHost *:80>

ServerName mysiteA.com

...................

mysiteB.conf

<virtualHost *:80>

ServerName mysiteB.com

..................

dockker-compose.yml

    volumes:

      - ./httpd/sites:/usr/local/apache2/conf/sites


For apache log files, in your custom log folder:

custom_log:

mysiteA.access.log

myisteA.error.log


docker-compose.yml

volumes:

 - ./httpd/custom_log:/usr/local/apache2/custom_log


httpd.conf User amd Group should be a user and group that does not used by others, personally prefer www-data as it is the default for apache2 without docker
User www-data
Group www-data


No comments:

Post a Comment