More simple nginx port mapping

Added the possibility to easily change the ports that nginx listens to.
This is useful, for instance when Apache or Nginx already runs on the
host. With this change, it is no longer necessary to edit the
docker-compose file to modify these ports.

To deploy with alternate ports, add a `.env` file with the following
contents:

```
OPENEDX_NGINX_PORT=8080
OPENEDX_NGINX_TLSPORT=8443
```
This commit is contained in:
Frank Anderson 2018-11-13 08:48:33 -08:00 committed by Régis Behmo
parent b949a44a78
commit 2f9766a3a1
4 changed files with 26 additions and 2 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@ config/
data-*/
TODO
openedx/requirements/private.*
.env

View File

@ -1,5 +1,6 @@
# Changelog
- 2018-11-17 [Improvement] Custom nginx port mapping. :crossed_swords: @frob @frohro
- 2018-11-17 [Improvement] Add "make restart-openedx" command. :+1: @frob
- 2018-11-13 [Improvement] Facilitate install of extra XBlocks. Thanks @frob!
- 2018-10-30 [Bugfix] Fix rabbitmq restart policy

View File

@ -262,6 +262,28 @@ Additional requirements can be added to the `openedx/requirements/private.txt` f
make build-openedx
make run
### "Cannot start service nginx: driver failed programming external connectivity"
The containerized Nginx needs to listen to ports 80 and 443 on the host. If there is already a webserver, such as Apache or Nginx, running on the host, the nginx container will not be able to start. There are two solutions:
1. Stop Apache or Nginx on the host:
sudo systemctl stop apache2
sudo systemctl stop nginx
However, you might now want to do that if you need a webserver for running non-Open edX related applications. In such cases...
2. Run the nginx container on different ports: you can create a `.env` file in the `openedx-docker` directory in which you indicate different ports. For instance:
cat .env
NGINX_HTTP_PORT=81
NGINX_HTTPS_PORT=444
In this example, the nginx container ports would be mapped to 81 and 444, instead of 80 and 443.
You should note that with the latter solution, it is your responsibility to configure the webserver on the host as a proxy to the nginx container. See [this](https://github.com/regisb/openedx-docker/issues/69#issuecomment-425916825) for http, and [this](https://github.com/regisb/openedx-docker/issues/90#issuecomment-437687294) for https.
### Help! Your containers are eating all my RAM/CPU/CHEESE
You can identify which containers are consuming most resources by running:

View File

@ -41,8 +41,8 @@ services:
image: nginx:1.13
restart: unless-stopped
ports:
- "80:80"
- "443:443"
- "${NGINX_HTTP_PORT:-80}:80"
- "${NGINX_HTTPS_PORT:-443}:443"
volumes:
- ./config/nginx:/etc/nginx/conf.d/
- ./data/lms:/openedx/data/lms:ro