I'm just getting started with Docker. With the official NGINX image on my OSX development machine (with Docker Machine as the Docker host) I ran up against the bug with sendfile and VirtualBox which means the server fails to show changes I make to files.
The workaround for this is to use a modified nginx.conf file that turns off sendfile. This guy's solution has an instruction in the Dockerfile to copy a customised conf file into the container. Alternatively, this guy maps the NGINX configuration to a new folder with modified conf file.
This kind of thing works OK locally. But what if I don't need this modification on my cloud host? How should I handle this and other differences when it comes to deployment?
You could mount your custom nginx.conf into the container in development via e.g. --volume ./nginx/nginx.conf:/etc/nginx/nginx.conf and simply omit this parameter to docker run in production.
If using docker-compose, the two options I would recommend are:
Employ the limited support for environment variable interpolation and add something like the following under volumes in your container definition: ./nginx/nginx.${APP_ENV}.conf:/etc/nginx/nginx.conf
Use a separate YAML file for production overrides.
Related
I want to add a new module to nginx but its on production and deleting nginx configuration is not an option.
After a bit of research I noticed that I have to reinstall nginx in order to add a module to it.
So my question is, is it possible in any way to reinstall nginx (and executing the ./configure command without messing up the current nginx configuration?
All I need is to generate the .so file to copy it to the existing /usr/lib64/nginx/modules directory.
I have a problem, with the plugin WP2Static in wordpress, when generating statics files, the folder is created well but not the files.
Export log:
cURL error: Could not resolve host: statics.mydomain.com
I'm using a VPS with Debian 9.
wordpress version: 5.2.1
WP2Static version: 6.6.5
I use Docker to generate my wordpress.
PS: The domain name used does not exist (statics.mydomain.com), I add it to the hosts file.
Target Directory:
/var/www/html/statics/site1
I installed the project on a VirtualBox and the plugin works fine. The problem must come from the DNS but I can not find the solution!
Have you ever had this problem ? Do you have any suggestions?
Thank you so much!
This is as you suspect a DNS resolution issue.
When you add the entry to your hosts file, I presume this is on your host.
The docker container running your application also needs to know where statics.mydomain.com resolves to.
Add an entry to the hosts file within your container running WordPress. You can then test by running cURL on CLI within that container.
WP2Static uses WordPress's knowledge of the Site URL and Home URLs from its Settings area. Ensure that these are also set to statics.mydomain.com and not overridden via wp-config.php.
This is probably a stupid question but I am running rocket.chat deployed w/ docker compose. I'm trying to customize the app but I don't know where to access the source codes. I don't really have full grasp of what docker is. Their docs are too confusing for me to understand. Any help? Can anyone direct me to the right direction?
Usually the files are stored on a folder that is specified in the Dockerfile. In the case of Rocket.Chat, this is the /app folder, inside the container.
I strongly suggest you do not edit source files directly inside your docker container. Rocket.Chat files inside a container are a compiled version and not the original source files.
If you still need access to that container files, you can access your container by running:
docker exec -it _your_container_name_ /bin/sh
Trying to deploy a Docker image in AWS Elastic Beanstalk running on a single instance for now. It all works fine, apart from WebSockets which I am using through Socket.IO.
Another post suggests to remove nginx, but that is either not possible anymore or just not an option for deployments with Docker.
I have a python script that changes the nginx configuration to allow WebSocket connections. When I ssh into the instance and run that script, it works. However, that part of the nginx configuration does not exist yet when ebextensions are run, so I cannot run this script automatically.
If you want to try it yourself, I am trying to deploy databench_examples. It is working when you deploy this with eb init and eb start and then ssh into the instance and go to /var/app/current and run sudo python nginx_socketio_conf.py which changes the nginx configuration file. If it is not working, you see a 500 error in the browser console for the Socket.IO handshake when running the simplepi analysis.
You're correct that the nginx configuration file does not exist when ebextensions are run. Here's why: that config file is dynamically generated after the application is deployed because the port mapping for the Docker container isn't known until after the container stops. So your awesome Python script executed by ebextensions doesn't have a config file to operate on.
Another conventional approach doesn't work, i.e., writing the nginx config file to /etc/nginx/conf.d because the location directive has to exist inside the server block in the sites_enabled config. So that's a no go.
I created a PR to illustrate an approach that will work: https://github.com/svenkreiss/databench_examples/pull/3 This is an undocumented technique that drops the Python/nginx mutation script into the right place in Elastic Beanstalk's hooks directory. The script is then executed by Elastic Beanstalk immediately after the nginx configuration is generated (Elastic Beanstalk will run executable scripts in the hooks subdirectories in alphabetical order, hence the 01_ prefix.
Thanks,
Evan
I have installed Nginx in our redhat machine using rpm. Now we want to add nginx-rtmp module, but inorder to add new module as per the document i need to build it by downloading the tar ball. Does it mean that i have to remove the rpm and install it as per the document.
Ref: https://github.com/arut/nginx-rtmp-module/wiki/Getting-started-with-nginx-rtmp
./configure --add-module=/usr/build/nginx-rtmp-module
make
make install
With nginx 1.9.11, it's not necessary to recompile the server, as they added support for dynamic modules. Take a look here:
https://www.nginx.com/blog/dynamic-modules-nginx-1-9-11/
Unlike Apache, all modules, including the 3rd party modules, are going to be compiled into nginx. So every time you want to add a new module, you have to recompile nginx.
So yes, you have to install it as per the document. There is no much value of keeping 2 nginx runtimes on the same server any way. So you may also want to remove the previous nginx.
I had a similar problem where the auth-pam module broke after an upgrade. Here's what fixed it for me (debian stretch/sid, nginx 1.10.2):
apt install libnginx-mod-http-auth-pam
ln -s /usr/share/nginx/modules-available/mod-http-auth-pam.conf /etc/nginx/modules-enabled/50-mod-http-auth-pam.conf
The config file contains a single “load_module” directive which tells nginx to dynamically load the module on startup. As jekennedy mentioned, this would only apply to newer versions of nginx that support dynamic module loading.
Yes, you have to uninstall nginx (installed via rpm) and re-install it according to the mentioned document that is from source file. There are some disadvantages of installing nginx using source, like you cannot use nginx as a service. Here, you can find instructions to do same thing with all the functionalities you get while installing nginx using OS-respective packages.
Following the steps in this post from the nginx blog page called "Compilation of Dynamic Modules for NGINX Plus", i could compiled the RTMP módule, downloading the nginx-rtmp-module from Github and import it on my webserver.
Regards.