Download Docker httpd image source files - docker

I am new to docker and I am trying to enable SSL and HTTP2 using the official httpd docker image.
My Dockerfile is as follows:
FROM httpd:2.4
COPY ./ /usr/local/apache2/htdocs/
COPY ./certs/server.key /usr/local/apache2/conf/
COPY ./certs/server.crt /usr/local/apache2/conf/
COPY ./conf/httpd.conf /usr/local/apache2/conf/httpd.conf
COPY ./conf/httpd-ssl.conf /usr/local/apache2/conf/extra/httpd-ssl.conf
I am facing issues while launching the docker container as the file I was editing was of a different source than what the official httpd image being used by docker.
AH00534: httpd: Configuration error: No MPM loaded
For instance, my httpd.conf doesn't have values like:
<IfModule !mpm_prefork_module>
#LoadModule cgid_module modules/mod_cgid.so
</IfModule>
<IfModule mpm_prefork_module>
#LoadModule cgi_module modules/mod_cgi.so
</IfModule>
whereas the one I got hold of a file from (mentioned as official)
https://github.com/jnbt/docker-httpd/blob/master/httpd.conf has the values for mpm modules.
I tried searching for the source through all the links mentioned at https://hub.docker.com/_/httpd but in vain. Can I get hold of the official files(httpd.conf and httpd-ssl.conf) so that I can make the necessary changes to them and build the docker image and run it?
Thanks!

Related

Container based Nginx configuration

Seeking help from developers familiar with Wodby container management. The main objective is changing the MIME Types that are gzipped. I'm confused with the documentation for customizing my Nginx container. The documentation:
https://wodby.com/docs/1.0/stacks/drupal/containers/
suggests I copy "/etc/nginx/conf.d/vhost.conf", modify it, deploy it the repo and use an environment variable to include it. My problem is, even if I could find this file, which is not mounted on the server when created via Wodby, it does not appear that I'm actually able to change the MIME types or the default_type as they are already defined in the nginx.conf file.
I have also attempted to modify the Wodby stack to mount the /etc/ directory so that I could manually edit the nginx.conf file if I had to, but that only freezes the deployment.
Any help would be tremendously appreciated.
Two options
clone a repo https://github.com/wodby/nginx/, change the template file /templates/nginx.conf.tmpl as much as you need and build your own image. See Makefile (/Makefile) for the commands they use to build the image themselves. Use this image as the image for your nginx container from docker-compose.
Run a container with the default settings, shell into the container with docker-compose exec nginx sh and copy the nginx file from the container (use cat /etc/nginx/nginx.conf and copy it somewhere). Create a new file locally and mount it via the docker-compose.yml for the nginx container like
volumes:
- ./nginx-custom.conf:/etc/nginx/nginx.conf

I can't see my html when I built container with docker

I have my container running like this
in the file directory C:\Users\hailey\Desktop\GitTest Where my project file are.
# getting bse image nginx
FROM nginx
MAINTAINER hailey
COPY . /usr/share/nginx/html
This is my docker file and I want to run my html file, which located in C:\Users\hailey\Desktop\GitTest
When I accessed to http://127.0.0.1:8080/
I see only this page, which is not helloWorld.html
you can copy and replace testhelloWorld.html with index.html
COPY testhelloWorld.html /usr/share/nginx/html/index.html

How to modify nginx access and error log locations with dockerfile?

I am running nginx in a docker container. I have to RELOCATE the nginx log files from /var/log/nginx/error.log and /var/log/nginx/access.log to different locations. For this I need to modify the /etc/nginx/nginx.conf file in my docker image. What can I mention in my dockerfile to make this modification?
I do not want to re-write the nginx.conf file with commands like echo.
You don't need to rewrite using echos, it's easier than that.
Change the file nginx.conf to your needs.
Put it next to the Dockerfile
Add the following instruction to your Dockerfile: COPY nginx.conf /etc/nginx/nginx.conf

How to deal with custom nginx.conf files in Amazon ECS?

I basically have two docker images: nginx image and a php image, that I want to upload to ECS. Both are run by a docker-compose.
The nginx has a myapp.conf file that I want to copy from somewhere into the container's /etc/nginx/conf.d folder.
Whats the best way to deal with this?
Prepare your own nginx image and use the COPY command.
FROM nginx
COPY myapp.conf /etc/nginx/conf.d
Build it:
docker build -t mynginximg .
and use it in your compose files.

How to setup mass dynamic virtual hosts in nginx on docker?

How can I setup mass dynamic virtual hosts in nginx As seen here
except using docker as the host machine?
I currently have it setup like this:
# default.conf
server {
root /var/www/html/$http_host;
server_name $http_host;
}
And in my Dockerfile
COPY default.conf /etc/nginx/sites-enabled/default.conf
And after I build the image and run it:
docker run -d 80:80 -v www/:/var/www/html
But when I point a new domain (example.dev) in my hosts file and make a www/example.dev/index.html. It doesn't work at all.
The setup is correct and it works as i tested on my system. The only issue is that you are copying the file on a wrong path. The docker image doesn't use the sites-enabled path by default. The default config loads everything present in /etc/nginx/conf.d. So you need to copy to that path and rest all works great
COPY default.conf /etc/nginx/conf.d/default.conf
Make sure to map you volumes correctly. While testing I tested it using below docker command
docker run -p 80:80 -v $PWD/www/:/var/www/html -v $PWD/default.conf:/etc/nginx/conf.d/default.conf nginx
Below is the output on command line
vagrant#vagrant:~/test/www$ mkdir dev.tarunlalwani.com
vagrant#vagrant:~/test/www$ cd dev.tarunlalwani.com/
vagrant#vagrant:~/test/www/dev.tarunlalwani.com$ vim index.html
vagrant#vagrant:~/test/www/dev.tarunlalwani.com$ cat index.html
<h1>This is a test</h1>
Output on browser

Resources